CIS307: Homework 6: Communicating through Sockets
This homework is given April 18 and it is due May 1st by 10pm.
It is similar to homeworks 4 and 5. Much of what you will do
is "Behavioral Programming": writing code while not knowing
much about the meaning and implementation of the system services
that are being used. Support material is provided in class, in the Hints, and
by looking at the code available with the networking book by
Stevens.
Here are a trivial 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. It is started from the Unix shell and it is called without
any command line parameter. It creates a datagram socket, it binds it
to a port selected by the system, and prints out the identity of the port.
Then it waits to receive messages from the clients. When it receives
a message from a client it carries out the request and sends back
a reply on the same socket. It then waits for the next message.
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 host name of the computer on which the server is running
- the port as printed out by the Server
- the seed for the random number generator.
The client process, RAND_PROC, will determine the IP address of the
server computer, and will create and bind to a datagram socket.
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.
STORE_MANAGER receives messages that consist of, in sequence:
- A message code ['U' for SSTORE_UPDATE, 'G' for SSTORE_READ]
- The operands required by the corresponding operation [hence for
SSTORE_UPDATE, the 'U' will be followed by a SSTORE_ID value
and by a SSTORE_ELEM value, while for SSTORE_READ, the 'G' will
be followed only by SSTORE_ID.]
The STORE_MANAGER responses consist of the character representing
the operation requested, followed by the result of the operation
['0' for success, '1' for failure], followed by the values involved
in the operation [both SSTORE_ID and SSTORE_ELEM].
RAND_PROC and STORE_MANAGER will each log to their own private file the
messages they receive and send. [STORE_MANAGER writes to store.log.
RAND_PROC to RAND.xxx.yyy where xxx is the process id and yyy the
client host name (something like yoda, not yoda.cis.temple.edu).]
STORE_MANAGER and RAND_PROC will
respond to signal 1 by gracefully terminating.
ingargiola@cis.temple.edu