COSC 4377 - Introduction to Computer Networks

Spring 2012

MW 1:00-2:30pm at PGH347

InstructorOmprakash Gnawali

Homework 1 : Network Client / Server

Due: midnight January 25, 2012

In this assignment, we will write two programs: a client and a server. They will communicate with each other across the network using sockets.

We are going to build a networked chat program. One user will run a chat program on one computer. Another user will run a chat program on a different computer. The two chat programs will connect to each other and enable the two users to chat in real-time!

The first program is called chat_server, which is a socket server. The server will be launched like this:

./chat_server listen_port
Once launched, the server waits for connection on the given port.

The second program is called chat_client, which is a socket client. The client will be launched like this:

./chat_client server_ip server_port

Once launched, the client program connects to a server running on the given IP address and port. To find the IP address of the server, log in to the server machine, and type ipconfig.

When the two programs are running, the programs should echo whatever is typed in their stdin to the stdout of the remote program. For example, if the user that launches the server types, 'testing' and presses enter, the word testing should appear on the client's screen. When the user running the client types something and presses enter, the text should be echoed on the server's stdout. It is most convenient to do this testing by opening two terminal windows on the same machine. That way, you can run the client in one window and run the server in the other window.

Optional: Once the basic chat feature is working, change your program so that the text is sent across the network as each character is typed.

Compiling and Running

It is perfectly fine for you to work on your own Linux machine. We have provided each student with an account on a Linux machine called Regardless of where you do your assignment, your assignment must compile and execute on bayou.


Put your source code into a folder with the name: uhid_hw1, where uhid is the prefix of your email address. There should be a single Makefile in that directory. When we run make on that directory, it should produce two executables chat_server and chat_client. Put a README.txt in the directory describing anything unusual (e.g., limitations) of your implementation. Then, zip the directory and upload the zip file using Blackboard.