Directions for using the Networking API


(Material in boldface below are commands you are supposed to type - or examples of what you might type.)


I downloaded the software into a directory I maintain for my classes. I want you to make your own copy of the software.

Log in to one of the Sun Workstations. Go to your home directory or some subdirectory of your home directory and do these commands:

mkdir CS3000

cd CS3000

cp /user/student/jsclass/CS3000/CNAIAPI/chapter3-api.tar .

(Be sure to type the final period, after a space -- that means 'copy it here')

Next 'unpack' the software:

tar xvf chapter3-api.tar

Do an "ls" to see what files you have.

cd cnaiapi

ls

more README

cd make-solaris [[ not "compile-solaris" :-) ]]

type: make cnaiapi.o

Ignore the compiler warnings.

Do an "ls"

You will see object code for the make_contact, appname_to_appnum, cnaiapi_init, send_eof, await_contact, and cname_to_comp operations.

type: make apps

Do another "ls"

You will see that you now have (among other files) the following programs:

chatclient, echoclient, webclient, chatserver, echoserver, and webserver.


ECHOSERVER and ECHOCLIENT
run the echoserver:

echoserver 27123 & [[ but use a different port number between 1025 and 32767]]

type: jobs

This shows that the server is running

Run the echoclient

echoclient localhost 27123 [[ but use a different port number -- the one you used for the echoserver (above).]]

Respond to the input prompts for a while and then do a control-D. This will cause both client and server to exit.

Start up your server again and work with a partner. Use your client to interact with your partner's server. When ready, enter control-D to 'kill' both your client and your partner's server.


CHATSERVER and CHATCLIENT
Work with your partner again ... one of you starts the chatserver and the other connects with the chatclient.

For example, on sol one of you does:

chatserver 27145 [[ but use a different port number between 1025 and 32767]]

(Note that this time you don't use the ampersand because the server has to be "in the foreground" in order to be able to write to the screen.)

and the other partner does:

chatclient sol 27145 [[ but use a different port number -- the one your partner used with chatserver.]]

After that use the server and client to chat a little. When finished, one of you should enter a control-D at your "Input >" prompt. The effect will be to terminate the client and server.


WEBSERVER and WEBCLIENT
Run the webserver. For example, you could type

webserver 27145 & [[ but use a different port number between 1025 and 32767]]

Then open a web browser and connect to your partner's webserver with a URL like this:

http://alcyone.csustan.edu:27145/ [[ except use your partner's hostname and port number ]]

Next try a URL for the time, for example:

http://alcyone.csustan.edu:27145/time [[ except use your partner's hostname and port number ]]

Also try something like:

http://alcyone.csustan.edu:27145/fakefilename [[ except use your partner's hostname and port number ]]

to see if you get the "not found" error message.

To kill the webserver

type: fg %1

to put it in the foreground, and then do a control-c to kill it.

Next try the webclient on some URL's -- you could use it to get my homepage:

webclient splendor.csustan.edu /~john/js.html 80

Also: use your webclient to connect with your partners webserver. For example, commands like:

webclient vega.csustan.edu /time 27145 [[ except use your partner's hostname and port number ]]

and

webclient vega.csustan.edu / 27145 [[ except use your partner's hostname and port number ]]