Programming Assignment 4

Objective

The objective of this assignment is to further practice socket programming by writing your own Chat application. You will implement the same application using two different protocols: a centralized and a decentralized chat protocol.

Assignment: Chat Protocol

The assignment consists of implementing two components: a chat client and a chat server. In the first implementation, the server maintains information about the clients that have registered with a specific chat group and dispatches the messages sent by the clients. The server should use select() or poll() to perform I/O multiplexing among the clients (i.e., no busy wait). In the second implementation, the server only serves as registry, maintaining contact information for all clients, but not dispatching any messages on behalf of the clients. That is, clients talk directly to each other.

Client

Clients can communicate with others by registering with a 'group'. All received messages (from other clients) should be immediately sent to standard output. Clients should be invoked with After successfully contacting the server, the client should support the following commands: This allows a client to send a message to a group. This registers the client with a group, allowing it to receive and send messages from/to the specified group. With 'leave' a client indicates that it wants to stop sending and receiving messages. This closes the client application.

Server Implementation 1

The server is started with When a client joins a group, the server registers the client with the corresponding group. A client can be member of multiple groups simultaneously and duplicate join requests must be discarded. Similarly, when a client requests to leave a group, the server removes the client from the corresponding group; if a client tries to leave a group in which it is not a member, the request must be discarded. When the server receives a send request message for a group, the server delivers the message to all members of the group. The message format should be as follows: "ClientName: msg".

Server Implementation 2

In the second implementation, the server behaves as before, except that it will not forward any messages. Instead, at registration, the server informs the new client about all existing clients (contact information) and the client will directly establish a connection with all other clients. All messages are then sent directly to all other clients. When a client leaves a group, it will terminate the connections to the clients of that group and inform the server with a 'leave' message, which in turn will inform all other clients. You can assume that there are no more than 5 available groups and at most twenty clients in the system.

Extra Credit (10%)

Implement an extension such that the server removes contact information of clients it assumes to have crashed. Do this by having each client send a "HELLO" message to the server periodically. If the server has not received a "HELLO" message from a client for a time of n*period, it removes the client's contact information from all groups it has registered with and informs all other clients of these groups.

Submission

The due date for this assignment is April 28th, 2009, 11am EST. You will use the drop-off boxes in the course directory (you will find a box with your login name). Make a directory called "project4" and place all required files into this directory (either individually or as one tar file). Only one team member has to do this! The required files are: all source files, a Makefile, and a document called README (ASCII file) or readme.ps or readme.pdf (postscript file), which describes a project summary, your solution approach, any encountered problems and how you solved them, any unresolved issues, and a usage explanation. Make sure to provide the names of all team members on the project summary.
Late submissions will not be accepted.