Network Programming

Project 2

30 Points

For this project you are to prepare an iterative TCP client/server pair to implement a simple class scheduling tool. On orca you can use the sch command to search a copy of the available course offerrings. With the command "sch sp csc101 eng403" you get

		Schedule information for Spring 1999
	 Oct 20 09:31 /orca/seyfarth/www/schedule/spring.new
 
3767  CSC101    01  3   3     MWF TEC COMPUTER SCIENCE I GARRAWAY HUGH     
3772  CSC101    02  3   4     MWF TEC COMPUTER SCIENCE I ALI ADEL          
3777  CSC101    03  3   D     TT  TEC COMPUTER SCIENCE I STAFF             
3782  CSC101L   01  1   1-2   M   JST COMP SCI I LAB     STAFF             
3787  CSC101L   02  1   1-2   F   JST COMP SCI I LAB     STAFF             
3792  CSC101L   03  1   7-8   W   JST COMP SCI I LAB     STAFF             
3797  CSC101L   04  1   A-B   TUE JST COMP SCI I LAB     STAFF             
3802  CSC101L   05  1   NIGHT TUE JST COMP SCI I LAB     STAFF             
5790  ENG403    01  3   E     TT  LAB LANG ST FOR TCHRS  EZELL JEANNE      

This is somewhat easier than reading the printed schedule booklet and can help a lot. Your goal is to implement the command "rsch" which does the same job remotely. You can simplify the requirements by using only the spring.new file listed above. The programs should be named rsch and rschd. You may use C or C++.

Client Usage Requirements

The rsch client needs to use a command line interface like sch. It does not need to specify the semester using f, sp or su like sch. Instead it can use just the spring data.

To make it simpler, the client can be programmed to accept and optional server hostname on the command line with orca being a default name. To indicate a different host, the user would enter "-h hostname" immediately after the program name and before the remaining words.

The client should have a default port number which can be over-ridden by adding "-p port_number" after the optional hostname.

The words after "rsch" and the optional parts are course names like "CSC101". Course names are in upper case in the file and are in columns 7 through 12. We will let "CSC101L" match "CSC101".

The words on the command line are most likely to be in lower case. You should convert them to upper case before comparing with words in the data file.

Server Usage Requirements

The server needs to be started with the name of the data file specified. If two parameters are specified on the command line, the second is the port number to over-ride the default.

Communication Requirements

First the server must be iterative. There must be only one active client at a time.

One invocation of "rcsh" should result in exactly one connection to the server. Each course request from the client should be a separate request to the the server. You can decide how requests and replies are composed within those limits.

Efficiency Issues

The data file should be read completely when the server starts so that clients will not have to wait on disk I/O.

The server should implement some strategy to speed up the searching for matching data. Sorting and binary search would be fine. You are encouraged to use qsort if you wish to sort. A hash table with chaining would be fine.

Be aware that some schedule entries occupy several lines in the input file. The first line has the course registration code in columns 1-4, but these are blanks in the subsequent lines for the class.

Testing and Report

Please turn in a written report describing the communication protocol, the way the server stores and searches the data and how the client performs.

Of interest in testing is the elapsed time for the client in comparison to sch on orca. Simply use "time rsch csc101 eng403" to get the time. Feel free to use different courses.

Source Code

Please submit your source code along with "README.rsch" which should describe what I need to do to compile the programs.