Fall 2001 CSCI 363 Homework 3

This assignment is due Thursday, 4 October.

The task

In this assignment you are to write a TCP client program to communicate with a TCP server presently running (hopefully) at port 3630 on tryon.cs.unca.edu. The server program will ask you for your name and then ask you to solve a simply mathematical problem. Here's an example of a successful interaction with the server. The client's input is indicated like this.

Name?
CSCI 363 networking guru
573043+742051=
315094
good

The server asks the client to add two six-digit numbers modulo 1000000, that is to compute (x + y) % 1000000 in the C/C++/Java programming language. The client must respond with a six-digit answer, using leading zeros if appropriate. Client requests and responses must all be terminated with telnet's standard carriage return-line feed ("\r\n") sequence.

If the client's responds with a properly formatted, but incorrect, answer, the server will reply with bad rather than good. If the client's response if not properly formatted, the server replies with ugly. Finally, if the client does not respond quickly, the server will reply with late.

Making the task a little harder

There are a couple of unusual features of the server that are designed to make sure you write a robust program and don't just use telnet and a calculator.

First, the program has two timers. The user name must be entered within ten seconds, and the numeric response must be entered within one second. If the client response is too slow, the server will close the connection.

Second, the server has a random "stall" in its requests. In particular, it will sometimes write a sequence of characters and then stop for a second. You'll need to read the server's input carefully to make sure you get the entire input line.

Making the task a little easier

Almost all server responses are logged at the following URL:

You can use the above link to check the format of the log. Note that the name of the connecting client machine is logged along with any client input. If the assignment gets frustrating, don't send any four-letter words. We'll know where they come from.

You are also free to look at the source for the server. It consists of the eight files shown in the following table.

AddServ.c The main routine
lineIOAddServ.c Server's line transmit/receive routines
lineIOAddServ.h Prototypes for lineIOAddServ.c
logAddServ.c Server's log routines
logAddServ.h Prototypes for logAddServ.c
parseInetAddr.c Routine to lookup a host by IP number
parseInetAddr.h Prototypes for parseInetAddr.c
Makefile  

The server is written in plain-C. The code was compiled on a Compaq tru64 Unix computer but can be easily ported to Linux.

Turning in the assignment

Your team scribe should create a directory called csci/363/home3 using the following commands (which should be familiar from CSCI 255):

The code to solve the problem should then be deposited into this directory. You can write your client in any programming language commonly available on a Windows or Unix computer.