CIS307: Homework 6: Communicating through Sockets

This homework is given November 28 and it is due December 8 by 5pm.

It is similar to homework 5. But now communication between clients and server is not taking place in a single computer using pipes, it can take place across networks using sockets. Support material on the use of sockets is provided in class, in the Unix notes, and by looking at the code available with the networking book by Stevens. Here are a trivial client and server, here are another client and server, and here are one more client and server.

Now the STORE_MANAGER is a server process running on a computer, say Snowhite.cis.temple.edu. It is started from the Unix shell and it is called with a command line parameter, the name of a port (say, a number over 5000 and less than 65536). It creates a datagram socket, and it binds it to the specified port. Then it waits to receive messages from the clients. When it receives a message from a client, it creates a thread and gives the request to it together with information on the requestor (you need it in order to send information back). The thread carries out the request and sends back a reply on the same socket. It then terminates. In the meanwhile STORE_MANAGER waits for the next message which it handles in a similar way.

A client process RAND_PROC is also started from the Unix shell on the same or on a different computer. It is given three command line parameters:

The client process, RAND_PROC, will use a datagram socket to communicate with the server. RAND_PROC will send messages to the server (as identified by the IP and by the port specified in the command line) through this socket and will retrieve messages from this same socket.

Both the client and the server will use timeouts when waiting for messages. At the timeout they print a warning message and then they go back to waiting.

RAND_PROC and STORE_MANAGER will exchange messages and log in the same way as they did in homework 5.
The program should keep operating correctly even if you launch a number of copies of RAND_PROC, perhaps on different computers.

STORE_MANAGER and RAND_PROC will respond to signal 1 by terminating gracefully.

ingargiola@cis.temple.edu