CS 3733 Operating Systems, Spring 2007 Assignment 5


Due April 30, 2007
Since this is the last assignment it must be finished by noon on the due date. Be prepared to demonstrate your programs.

In this assignment you will write a threaded parallel network server. You may do this in either Java using Java threads or C using POSIX threads. You will need a client to test your server.

Part 1: The client
The client will take two command line parameters. The first is the name of a remote host and the second is a port number. It will make a connection to the remote host on the remote port. Anything that comes in on standard input will be sent to the network. Anything that comes in from the network will be displayed on the screen. If you plan to do the project un C on a UNIX system, you can use the program client2.c from USP, chapter 18. If you are doing the project in Java, you can use the client program here.

Part 2: A simple threaded parallel server
If you are doing this assignment in C:
Convert the program serverp.c into a simple threaded server, servert.c. It should behave like serverp but is should create a new thread to handle each connection. Be careful about when you close the communication file descriptor. The thread uses this file descriptor directly, unlike a child which uses a copy of the file descriptor.
If you are doing the assignment in Java:
Convert the Java serial server from class into a parallel server.

Test your server with several copies of the client program from Part 1 to make sure it is working as a parallel server.

Part 3: The full server
The server takes a port number as a command-line parameter. If will keep track of the number of connections that have come in and for each create a disk file containing the information received from the remote client. The name of the file is a 3-digit number representing the connection number. The first file will be 001, the second 002, etc. Additional characters should be added to the file name when 1000 connections have been made, but you do not have to test this feature.

The server will keep track of the number of connections made, the total number of bytes transferred to clients for compelted connections, the total number of completed connections, and the total number of open connections. These numbers should always be consistent: total = open + completed.

When a client makes a connection, the above information is sent to the client as a stream of bytes that can be directly displayed on the screen. Format the output in a simple, user-readable format on several lines.

All data that comes from the client should go into the created file. The file should be closed when the remote client closes the connection.

The server will also keep a log file called server.log which will record events that occur while the server is running. Each event should appear in the log on a separate line in a readable format. The events that should be logged are:

The log file should be preserved between runs of the server. Each time the server is started, it appends to the old log file if one exists.

You can write the server either in C or in Java. In either case, the server should work with both provided C and Java clients. Client and server should be able to run on machines with different operating systems and architectures.

The server should use appropriate synchronization and check for all errors. If an error occurs, the error is entered in the log file. The server should not exit due to a network error.

Make sure you use the appropriate synchronization.

Extra Credit:
Write both Java and C versions of the server. Client and server should be able to run on machines with different operating systems and architectures.

Handing in your assignment
Use this cover sheet. You will demonstrate your server in class on the due date.

Instructions for demonstrating your assignmnet are here.