CS-596 Client Server Programming

Programming assignment #1b
Fortune Server & Client
Assignment Due Data: April 3, 1995


Your boss was really happy with your previous client-server fortune application, but now that this service is available, the users have been complaining about limited features. All the complaints and suggestions were collected and it is now your task to upgrade the software to meet the new specifications.

One things that is VERY important is that old clients need to continue to work as before, regardless of whether they are communicating with your old server or your new server. Also, your new server may be contacted by either your old clients or your new clients.

New Requirements

Here are a list of features that want to see:

Besides the user requests, your boss also has a request because she wants to keep track of usage of this service. She is afraid that people are spending too much time just reading fortunes. Furthermore, she wants to be able to add access restrictions to the service.


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

  1. Design and document the upgraded protocol you are going to use. Keep in mind that you need to have upward compatibility with the previous assignment.
  2. Design and document a configuration file which can be used by both the server and client.
  3. Upgrade your fortune server to conform to the new protocol.
  4. Upgrade your fortune client to conform to the new protocol.


Configuration File

In order to satisfy the users' request to not have to specify a server name and port number, you need to use a configuration file. This file should contain information that both the server and client can use. However, it should still be possible to specify all the appropriate information that is contained in the configuration file on the command lines of the client and server.

The configuration file needs to be easy to understand and modify. Comments should be allowed and the order of information in this file should not matter.

Both the client and server need to be able to find the configuration file. They both need to look for it in the following order (and stop looking when found):

  1. The configuration file is specified as an option on the command line
  2. The configuration file is specified in the FORTUNE_CONF environment variable
  3. The configuration file is located in the user's home directory and is called .fortunerc
  4. The configuration file is specified as a compile-time option

Command Line Options

Both the client and server need to be able to recognize several command line options. These options need to be parsed using one of the following methods:

Keep in mind, that if you are going to reinvent the wheel by writing your own argument parser, it needs to be in its own separate library and have its own documentation.

Both programs need to have some way to letting the user know how to use it. This is normally done by using something like "-h" or "-help". The information displayed should be short but complete. You may NOT use a datafile to contain this information.

New Client Options

Besides the options you need to add for dealing for configuration, the client need to recognize the following new options:

Request an offensive fortune. The client should tell the server to start the fortune command with the -ooption to retrieve the fortune.
The client should delay after the fortune is displayed. The length of the delay should be determined by the length of the displayed fortune and the reading rate of the user. Note that the client has to do the delaying, not the server.


The server needs to be able to start the fortune program with an optional -o argument to get an offensive fortune.

There may be cases in which the fortune program is not available or that access to fortunes is restricted for certain clients. The server should report an appropriate error to the client in this case.

Organization of your sources

Even though this project is not large, you are expected to reuse large parts of it. To make the reuse easier later on, you should follow some rules now:

Turning In the Assignment

As before you will need to turn in three copies of your work. Printouts should be on 8.5 x 11 paper and each set should be stapled together. Documentation should preferably be written using a word processor or other text formatting tool. Source code should be laser printed using either enscript -2rGor vgrind .

The order of pages is important. Please use the following order:

  1. Manual for server and client
  2. Configuration file specification
  3. Protocol specification
  4. Design document (split up into server design and client design)
  5. Source code for the client (Starting with the file which contains main() and ending with the Makefile)
  6. Source code for the server (Starting with the file which contains main() and ending with the Makefile)
  7. Source code for the libraries and their Makefiles you have created
  8. Main Makefile

Good luck.

Send any questions to Andrew@sdsu.edu or Whitney@cs.sdsu.edu