Content area
Transmission Control Protocol/Internet Protocol (TCP/IP) is the name given the set of communications standards that make possible the vast network of computers known as the Internet. The hardware and software required to implement TCP/IP communications from within HyperCard include a Macintosh with a direct connection to the Internet, any version of HyperCard, MacTCP, and the XCMDs from the HyperCard TCP Toolkit. A simple algorithm for establishing a connection, performing a dialogue with the remote computer, and closing a connection is presented. Using this simple algorithm with MacTCP, 2 information-gathering tools have been developed - Mini-Atlas and ListManager.
THE INTERNET
Transmission Control Protoco/Internet Protocol (TCP/IP) is the name given the set of communications standards that make possible the vast network of computers known as the Internet. With these standards one can use telnet to log into remote computers, transfer files from remote sites with file transfer protocol (FTP), and send electronic mail to remote computers. If a Macintosh computer is directly connected to the Internet, then the user probably runs communications programs like BYU/NCSA Telnet and TN3270, XferIt, or an electronic mail gateway to remote computers. These programs are general-purpose tools for remote access; they are not intended to provide access to specific information services. With HyperCard it is possible to create specialized information-gathering tools to access specialized information services.
REQUIREMENTS
The hardware and software required to implement TCP/IP communications from within HyperCard include a Macintosh with a direct connection to the Internet, any version of HyperCard, MacTCP and the XCMDs from abling the Macintosh to implement the TCP/IP protocols. It is available from the Apple Developers Association (APDA) (1-800-282-2732).
Finally, the HyperCard TCP Toolkit is a set of XCMDs that calls the routines within MacTCR XCMDs are compiled portions of programming code, usually written in the C or Pascal programming language, that can be added to HyperCard stacks, adding additional functionality to the Hyper Card HyperTalk language. The TCP Tool it is available from APDA, America Online, and a number of anonymous FTP sites.(1) The following descriptive text was taken from the introductory card of the HyperCard TCP Toolkit.
The HyperCard TCP Toolkit consists of a set of HyperTalk commands and functions which allow HyperCard stacks to establish TCP connections and send data across them. There is also a function for performing name-to-address translation.
A connection is established using the TCPActiveOpen function, which establishes a connection with the remote socket (a connection between computer processors allowing them to communicate in a fast, reliable manner) and returns a connection ID. This connection ID is used to specify which connection to send and receive data on for the TCPCharsAvailahle, TCPSend, TCPRecvChars, TCPRecvUpTo, and TCPRecvMsg commands and functions. The TCPState function returns the current state of the connection. To gracefully close a connection, the TCPClose command is called; the HyperTalk script should then wait for the connection to close, by calling TCPStatus until it returns "closed," and then calling TCPRelease. (A call to TCPRelease, without first closing the connection, will abort the connection.)
Alternatively, TCPPassiveOpen will allow a connection to be accepted on a particular socket. The TCPState function can then be called to determine when the connection is established.
BASIC ALGORITHM
The following is a simple algorithm for establishing a connection, performing a dialogue with the remote computer, and closing a connection.
1. Resolve the remote computers name or address with TCPNameToAddr.
2. Open a connection to the remote computer with TCPActiveOpen.
3. Make sure a connection is established with TCPState,
4. Read incoming characters with TCPRecvUpTo.
5. Send outgoing characters with TCPSend.
6. If the dialogue is not complete, then go to step 3.
7. Close the connection with TCPClose.
8. Release the connection with TCPRelease.
Using this simple algorithm with MacTCP, two information-gathering tools have been developed: Mini-Atlas and ListManager.
MINI-ATLAS
Mini-Atlas is a client for the Geographic Name Server. The Geographic Name Server contains brief information about most United States cities and geographic landmarks. This sort of information usually includes the name of the place, the type of place (city, river, lake, mountain, etc.), the latitude and longitude, a remark, the county it is located in, the telephone area code, the zip codes, and the 1980 census population.
To query the Geographic Name Server manually it is necessary to follow these steps:
1. Open a TCP/IP connection to martini.eecs.umich.edu on port 3000.
2. Wait for the period (.) prompt.
3. Send a query in the form of a postal-like address; for example, Lancaster PA, Lake Erie, or Los Angeles.
4. Wait for the period prompt.
5. Logoff.
Notice the similarities between manually querying the Geographic Name Server and basic query algorithm listed in the section above. Querying the Geographic Name Server for "lancaster, pa" yields the following output during the Mini-Atlas session:
# Geographic Name Server, Copyright 1989, 1990 Merit Inc.
# All rights reserved.
# >>>NEW VERSION!!!<<< Use "help" or "?" for details.
lancaster, pa
0 Lancaster
1 42071 Lancaster
2 PA Pennsylvania
3 US United States
R county seat
F 45 Populated place
L 40 02 16 N 76 18 21 W
P 54725
E 357
Z 17600
Z 17601
Z 17602
Z 17603
Z 17604
Z 17605
bye
The HyperCard script in Mini-Atlas automates the above manual communications and query processes so that by answering one simple question the user can retrieve data from the Geographic Name Server without having to initiate the communications procedures manually. All the necessary HyperTalk code for Mini-Atlas is listed in appendix A. (Appendix A omitted) What follows are descriptions of essential parts of the code.
First, the Geographic Name Server's IP name is resolved (step 1 of the basic algorithm).(2)
put item 1 of TCPNameToAddr("martini. eecs.umich.edu.",,) into the IPAddress
If an error did not occur then a connection is opened with the IPAddress on port 3000 (step 2).(3)
put TCPActiveopen(theIPAddress, 3000,0) into connection ID
Again, if no error occurred, then wait for the period prompt with a handler called WaitForPeriod. This function waits for a linefeed character (ASCII character 10) and returns the character and the string preceding it (steps 3 and 4).
put TCPRecvUpTo(connectionID, linefeed, 60, empty) into theResponse
Once the Response is retrieved, the program determines whether or not it is the period prompt. If it is the period prompt, then the query is retrieved from the users input and sent with the SendLine handler. SendLine verifies the connection and sends the-Text (in this case, the query) (step 5).
if TCPState (connectionID) is "established" then
TCPSend connectionID, the Text & return & linefeed
end if
After sending the query, WaitForPeriod is called again. Not only does this handler wait for the period prompt, it also puts all incoming text into a field for later analysis. After the period prompt is sent from the server the connection is closed and released with the Disconnect handler where it calls the following two commands (steps 7 and 8; see figure 1). (Figure 1 omitted)
TCPClose connectionID
TCPRelease connectionID
The most difficult aspect of developing this information tool is creating a way to analyze the retrieved data. Mini-Atlas parses the retrieved data into records and creates new cards for each record. Each card contains four buttons and one field. The field contains the text of the retrieved data (see figure 2). (Figure 2 omitted) Three of the buttons are used for navigation. The last button reads the places latitude and longitude, converts them into screen coordinates, and literally pinpoints the place on a world map (see figure 3). (Figure 3 omitted)
Other things could be done with the data. For example, many place names could be entered and the distances between them calculated. Populations could be compared. The Mini-Atlas could be used to answer many simple reference questions about a place.
LISTMANAGER
Another, more interesting application is the ListManager a front end to LISTSERV programs operating electronic lists such as PACSL, AUTOCAT, and LIBREF-L. ListManager automates the procedures necessary to search the archives of these lists by keyword Boolean queries, turn off mail from the list temporarily, retrieve a list of the lists participants, or retrieve files from the lists. With the ListManager, the user can do all this and more simply by answering a few questions and clicking a few buttons. As the ListManager conducts a simple reference interview querying the user about LISTSERV needs, it creates a Simple Mail Transfer Protocol (SMTP) message. Using the XCMDs from the HyperCard TCP Toolkit, the ListManager sends the message to the user's mail server. In turn, the mail server forwards the message to the LISTSERV program, where it processes it and sends a reply to the user's e-mail address. There are two parts to the ListManager: the reference interview and the transmission of the resulting e-mail message. The reference interview process asks questions, and based on the answers to these questions, it asks other questions. When the question-and-answer process is complete, the result is an SMTP message. The first question asked is, What is your name? ListManager next asks for an e-mail address and the name of the users mail server. It then asks, To what list do you want to send mail? Then it asks, Do you want to send mail to the server or to the participants of the list? Users choosing "participants" are given the opportunity to write a posting. On the other hand, if "server" is chosen, users are presented with the various commands that can be sent to the server, such as subscribe, unsubscribe, index, get, and review (see figure 4). (Figure 4 omitted) See appendix B for Hypertalk scripts for ListManager. (Appendix B omitted)
Following are some example results of the reference interview process. If one wished to subscribe to PACS-L, then, using the authors e-mail address as an example, the e-mail query would be:
HELO ericmorgan.lib.ncsu.edu
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
FROM:<[email protected]>
TO:<[email protected]>
subscribe PACS-L Eric Morgan
QUIT
On the other hand, if one wanted to retrieve a list of all the files available from PACS-L, then the e-mail request would take the following form:
HELO ericmorgan.lib.ncsu.edu
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA
FRQM:<[email protected]>
index PACS-L
.
QUIT
Then, if one wanted to query the PACS-L list for messages (records) containing the terms "ALA" and "preconference" posted between May 1, 1990, and August 31, 1990 where the subject line sounds like "shikago,"(4) and one wanted the results sent in a user-defined author-subject format, then the e-mail query would appear as in the following example:
HELO ericmorgan.lib.ncsu.edu
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
DATA FROM:<[email protected]>
TO:<[email protected]>
// JOB Echo=No
Database Search DD=Rules
//Rules DD *
S ALA preconference in PACS-L where Subject sounds like shikago from 90/1/5-to 90/31/8
F AS: #.6RO "Record" From.25 "Author" Subject.8O "Subject"
IAS
.
QUIT
The output of a search similar to the one above looks like this:
>S 'ALA' preconference in PACS-L
-->Database PACS-L, 7 hits.
>F AS: #.6RO "Record" From.25 "Author" Subject.8O "Subject"
>IAS
Record Author Subject -- -- --001594 [email protected] ILL, Copyright and Internet Catalogs
003197 [email protected] LITA Human-Machine Interface Interest Group pl+
003468 [email protected] Screen design: since you asked
003540 [email protected] LITA Screen Design Preconference
003654 [email protected] Screen Design
005747 [email protected] Screen Design/Online Catalog project status re+
006113 [email protected].+Images in the OPAC
Finally, if the user wanted to retrieve record numbers 001594, 003468, and 006113 of the resulting set from the search above, then the e-mail query would be:
HELO ericmorgan.lib.ncsu.edu
MAIL FROM:<[email protected]>
RCPT TC:<[email protected]>
DATA
FROM:<[email protected]>
TO:<[email protected]>
// JOB Echo=No
Database Search DD=Rules
//Rules DD *
search * in PACS-L
print all of 001594 003468 006113
.
QUIT
Granted, an e-mail program could have created the first seven and last two lines of each of these examples, but everything in between is up to the user to supply. With the ListManager all one has to do is answer some simple questions. The program does the rest.(5)
After the message has been created, it can be sent by clicking on the "Send the message" button (see figure 5). (Figure 5 omitted) ListManager then resolves the senders mail server's IF or name address (step 1 of the basic algorithm). This is done with the TCPNameToAddr XCMD. Next, the user opens a connection to the mail server on port 25 with the XCMD TCPActiveOpen. Port 25 is the standard port for SMTP mail transactions (step 2). Once a connection is established, then ListManager begins to send the message line-by-line with the SendLine handler (steps 3,4, and 5). SMTP transaction prompts are numbers that correspond to a particular type of response. Numbers beginning with 5 are error messages. In general, numbers beginning with 2 or 3 mean there was no error and the dialogue can continue. Therefore, the ListManager uses a modified version of the WaitForPeriod function called GetResponse. GetResponse takes one argument, a digit we want to receive from the mail server. If GetResPonse "hears" the desired response, then the dialogue continues. Otherwise, an error is returned and the connection is closed (steps 7 and 8). After the entire text of the SMTP message has been sent, the connection is closed with the Disconnect handler (steps 7 and 8). After the connection is closed, the reply will arrive at the e-mail address the sender supplied to ListManager
SUMMARY
This article listed the necessary tools and outlined all algorithm for implementing TCP/IP communications with HypererCard. Two examples were then illustrated. In the first example, Mini-Atlas queries the Geographic Name Server and reformats the results into human-readable form, including placing them on a world map. In the second, ListManager uses a reference interview model to create all SMTP message any LISTSERV program call understand. The resulting message is then sent to a LISTSERV program, where it is analyzed and acted upon.
This article detailed the communications process because it is common to both applications. It is hoped that the communications process described here will spark the readers interest in creating custom information tools. The stacks listed in the appendixes have been modified to create a tiny stack (38K) that logs on to Dialogue, sends a previously saved search strategy, saves the results to another tea file, and logs off. Modification of the stacks in the appendixes has also resulted in applications to read UseNet news and implement FTP transfers. It would he possible to create
VAIS, Gopher, or World Wide Web clients simply by modifying the scripts given in this article.
The most difficult aspect of these applications is not the communications process but creating the messages and analyzing the received data. More effort went into translating the output of the Geographic Name Server into human-readable form that went into scripting the communications process. More toil was involved in learning the ins aid outs of the SMTP protocol and in creating an SMTP message that in scripting the communications processes involved in ListManager. The scripts described here exemplify one librarian's attempt to gain control over electronic information and present it to patrons and other librarians in a usable form.
NOTES
1. The author has found the TCP Toolkit at the following anonymous FTP sites:
akiu.gw.tohoku.ac.jp (130.34.8.9) /pub/mac/comm/MacTCP/mactcp-tool kit-1-0.hqx
ugle.unit.no (129.241.1.97) /pub/mac/mactcp-toolkit-1-0.hqx
src.doc.ic.ac.uk (146.169.2.1) /mac/mactcp-toolkit-1-0.hqx
To find other locations, telnet to an Archie server (archie.mcgill.ca. archie.sura.net. archie.ans.net, arcllie.unl.edu. arcllie.rutgers.edu. archie.funet.fi. archie.au, archie.doc.ic.ac.uk, or cs.huji.ac.il), logon as "archie," and issue the command "prog mactcp.
2. Each computer on the Internet has a unique number. These numbers are stored in distributed databases and administered by computers called name servers. Resolving an Internet name or address entails querying a name server for a remote computers unique number i.e., its address.
3. A part is analogous to a telephone extension. When one ca11s a particular telephone number the caller may want to talk to someone on a different extension. When one connects to a remote computer one may want to connect to a particular port.
4. Besides Boolean, adjacency, and date range queries, the LISTSERV software can conduct soundex searches. The ListManager specifies a soundex search with the "sounds like" qualifier. This gets passed on to the LISTSERV, where terms are analyzed phonetically.
5. For more information concerning the construction of SMTP mail messages, read RFC 821, Simple Mail Transfer Protocol, by Postel. It is available via anonymous FTP from nic.ddn.mil as /rfc/rfc821.txt. For a listing of valid LISTSERV commands and information concerning the construction of LISTSERV database queries, send the commands "get info" and "info database," respectively, to any LISTSERV program.
Eric Lease Morgan is Systems Librarian at North Carolina State University Libraries in Raleigh
Copyright American Library Association Dec 1992