CS-596 Client Server Programming

Programming assignment #1a
Fortune Server & Client


Setting

The hypothetical environment for which you will be programming consists of 100 UNIX workstations of various types and capacities. All these workstations are connected by ethernet and use TCP/IP. Most of the workstations have their own disks but these disks are to be used for "official" work purposes only. Because all workstations are on a bridged network, NFS traffic has to be kept to a minimum.

A fortune is a message (mostly funny) which is normally returned by the `fortune' program. However, the fortune program requires a large database of messages and when the operating systems of the workstations were installed, the system managers did not install the standard UNIX fortune program.

Recently, some of the workers have been asking for the `fortune' program to be installed on their workstations. Your task is to provide the fortune service without having to install the large database on every workstation.

Assignment

Design and implement both a fortune server and client which can be used by these people.

A user should be able to type `fortune' and get exactly one fortune displayed on the screen.

For example:

% fortune
My opinions have changed, but not the fact that I am right.
%
Your task is to create two programs: a client called fortune and a server called fortuned.

Steps

In completing this assignment, you need to follow the following steps:

  1. Design and document a protocol you are going to use. Keep in mind that this assignment is labeled 1a... This means that you have to design your protocol such that it will be easy to extend. Try to think of what kinds of things could be added to the protocol but don't make it too complicated.
  2. Design and implement your fortune server. This server will need to get fortunes from a database. You can do this using the fortune command on the system you are working on[1]. You should be able to test your server using the telnet of mconnect command. (Look in the man pages for these commands on how to specify a specific port to connect to.)
  3. Design and implement your fortune client.

Specifications

(Please keep in mind that these specifications are for the end product only. Feel free to do things differently during development.)

The server needs to be started with two arguments. The first argument will be the port number it will be listening on while the second argument is the path to the fortune program.

Once the server has been started, it should fork itself and print its PID (this is so that the server can easily be killed once it has started.) After this it should be able to accept any number of connections concurrently. When a new connection comes in, the server should fork and the child should deal with the connection with the client.

The client needs to be started with two arguments. The first argument will be the name of the host the server is running on and the second argument will be the port number your server is using to accept connections.

The only output from the client should be the fortune.

You will loose points if you violate the following rules:

Turning things in

The following needs to be turned in to get credit for the assignment:
Everything should be kept together in some way. Staples are fine.