Computer Science 308-435B

Basics of Computer Networks

McGill University, Winter 2001

Assignment 4: client-server programming using TCP/IP

Due date

Tuesday 10 April, official deadline. VisualCM will stay open for submission until Monday 23 April, 23:59 (no penalty for delayed submission).

Submission medium


Group work

This assignment may be done in groups of (up to) 3 people. The names and student IDs of all group members should appear on all submitted documents. The whole work should be submitted by each individual (copies).


The deliverable for this assignment consists of a number of files, all to be submitted via VisualCM. All files are submitted either separately or in the form of a single .tar.gz file.
All submissions must run on the SOCS UNIX Sun servers (willy, mimi, ...) !

  1. One HTML file index.html. The document discusses your design and implementation and gives some examples of use. The file should only refer to files in the same directory. Also document your code lavishly !
  2. One Makefile. Typing "make" should build the executables.
  3. One services.h to be included in various places which lists symbolic names for the services (SUM and PRODUCT).
  4. Once net_client.c. The net_client.c provides services to access the network, namely access remote procedures. The user must be able to link a client.c application with net_client.c to access functions int plus(int, int) and int product(int, int) on a server as if they were local. To find out which server (IP address and port number) provides plus() and product(), the client will contact the dispatcher. If the connection to the dispatcher fails, the client retries upto MAX_RETRIES times after a certain delay time. The delay time is initially RETRY_DELAY. Upon each retry, the delay is doubled. If the connection to the server fails, the client exits. A more realistic application would contact the dispatcher again.
  5. Once net_server.c. The net_server.c provides (remote) procedure/function services to connecting clients. The user must be able to link a server.c application with net_server.c to provide the actual function implementations int plus(int, int) and int product(int, int). Both functions will call sleep(DELAY) to emulate major computation (DELAY=30s). A server will announce its availability as well as services it offers and on which IP address/port to the dispatcher. Once it has finished doing so, it will listen to the advertised IP address/port to service client calls. The server should handle the SIGINT interrupt gracefully: before terminating, it must warn the dispatcher it is no longer available. The server must be implemented as a concurrent server.
  6. One dispatch.c (iterative server) which accepts connections from clients as well as from servers. The server will announce its availability as well as services it offers and on which IP address/port. This information will be stored in a table in the dispatcher. A lookup in this table will be perfomed to answer a client query (which server can process its requrest). Come up with a "reasonably fair" way of performing the lookup (such as round-robin).

Some remarks:


Check the Class Transparencies page to find more information about TCP/IP.

Hans Vangheluwe