COSC 4300 Networks and Internets

Fall 2014

Homework Assignment #8

Sockets
"The blaze of reputation cannot be blown out,
but it often dies in the socket;
a very few names may be considered
as perpetual lamps that shine unconsumed.
-- Samuel Johnson
Due: Wednesday, November 19th, 11:59pm CST
Submit: Turn in your entire kernel source code with a subdirectory "chat" for the UNIX source code using the turnin command on the Systems Lab machines.
Please run "make clean" in your compile/ subdirectory before submitting. Work is to be completed in teams. Only one team member should turnin, but it would be courteous to notify your teammate(s) when you do this. Names of authors should be included in all work. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline.

Unix Chat Server

Building upon the lab demonstration from November 10th, implement a Unix chat server, capable of echoing UDP-based messages to up to five clients. Your chat server should take a port number as a command-line option.

The protocol for the chat server is very simple. The first message sent to the server should be a null-terminated client string that identifies the user represented by the client. When a new client joins the chat server, a message announcing the new user should be sent to all connected clients.

Each subsequent null-terminated message from a client should be echoed back by the chat server to all connected clients, prepended by the corresponding user name.

If any client sends the message "exit", the chat server should exit cleanly.

BONUS: If a client sends the message "close", the chat server should close that client connection, announce that the user has left the session, and leave an open slot for potential new clients to join if the server already had five connections open.

Unix Chat Client

You may use the built-in Unix netcat utility "nc" for early testing of your chat server, but once the server is operational, construct your own client that obeys the protocol for connecting to the server.

Your client should take three command-line arguments: a server, a port number, and a user name.

Xinu Chat Client

Finally, adapt your echo shell command from the previous assignment to act as a Xinu-based version of your Unix chat client. If your IP routing module is working, you should have no trouble connecting to chat servers on the production Systems Lab workstations.


[Revised 2012 Nov 05 13:19 DWB]