CSCI.4210 Operating Systems
Fall, 2004
Client-Server Programming Assignment
You must work independently on this project. Do not show your code to other students and do not look at other students' code. Do not put your code in a public directory or otherwise make it public. However, you may get all the help you need from the instructors or TAs.

You will have to write four programs for this project, a simple file transfer client and a simple file transfer server for Unix and for windows. These will copy files from the client host to the server host or vice versa. Either of your clients should be able to communicate with either of your servers, and either client of anyone else in the class should be able to communicate with either of your servers, and your clients should be able to communicate with anyone elses server, regardless of platform.

The protocol

Every request from the client to the server and every reply from the server to the client will have an initial header. This will always be exactly 21 characters.
Content Length:xxxxx
You only see 20 characters, the last is the newline char. The x's will be replace by digit chars (in human readable form). These represent the number of bytes in the remainder of the message (padded with leading zeros if necessary).

The client can send three commands,

The server

When the server is started, it takes one argument, the port number to listen on. It should listen for connections, and create a separate thread for each connection. It should be able to maintain any reasonable number of simultaneous connections.

Each thread should listen for requests from the client and respond appropriately.

Your server should maintain a log consisting of all commands that it received, with the IP address of the client for each.

Your server should run as a daemon, not connected to a terminal. Since it is a major security loophole, make sure that you kill your server after you are through testing it.

Your server should be run in a directory with at least three files of varying sizes. At least one should be very large (> 10K). It should not have any subdirectories, and for security purposes, it should confirm that the first two chars of the file name are not .. (that's dot dot; this refers to the parent directory) and that the file name is a relative file name, not an absolute file name.

The client

When the client is run, it should take two arguments, the name of the machine on which the server is running (or its IP address) and the port number on which the server is listening.

The client has an interface with a human user. The user will type commands for the client. Here are the commands for the user. The meaning should be obvious.

dir
get filename
quit

The client should display a prompt > whenever it is ready for the next command from the user. After the dir command, the client should display the results on the terminal. If a get command is successful, the client should display OK on the terminal. In case of an error, the client should display a suitable error message to the user.

Each of the four programs will be graded independently, the servers will be weighted more heavily than the clients. The programs will be due at 11:59PM on Sunday Nov 28.