COS-461 Assignments: Socket Programming

Assignment 1: Socket Programming

Your first assignment is to build a server capable of receiving text messages from clients. The server should print these text messages on the standard output, but should not print any other messages such as debug information. From the server perspective, a message corresponds to the data received from a particular client during a communication session with that client. The server should be listening for text messages to a port known to the clients. The server should be able to queue connections from multiple clients i.e., it will handle the client connections sequentially, but should be able to accept connections from multiple clients. After servicing the current client to completion, it should proceed to the next. If multiple clients simultaneously try to send text messages to the server, the server should print them one at a time (in any order). Note that you don't have to implement an event-driven or multi-threaded server. Serving one client at a time is enough.

You should also implement a client to test the server. The client should receive the text message from standard input. The end of the message is marked by a control sequence which corresponds to hitting >ENTER< twice. This control sequence is also an instruction for the client to exit. The second newline of this control sequence should not be transmitted. Also, if your client reads the text message from a file via pipes, and reaches EOF without seeing the control sequence, then the client should still transmit the message and exit.

This assignment should be completed in ANSI C or C++. It should compile and run without errors in the FC 010 cluster producing two binaries called server and client. The server should take as its first argument the port to listen to. The client should take as its first argument the name of the host that the server is running on and the port that the server is listening to as the second argument i.e., you should run the client as "./client <server> <port>" and run the server as "./server <port>". If the server cannot bind to the port that you specify, a message should be printed on standard error and the program should exit. You shouldn't assume that your server will be running on a particular IP address, or that clients will be coming from a predetermined IP address. Both the client and server should generate an appropriate error message and terminate when given invalid arguments.

You should test your code with long text messages (of size at least 20KB), not just short ones. You can use pipes to redirect the standard input of the client and standard output of the server. You should also test your code with multiple clients. (at least up to 5 simultaneous clients)

You can find a skeleton framework in which you should implement your code here. This includes two files---"server.c" and "client.c" for implementing the server and client, respectively---as well as a Makefile for producing the executables and a README file which you should read and fill out. You should submit a tar file that includes these files after implementing the proper functionality described above. The Makefile includes a method for making the tar file for you. Simply run "make tar" to produce a tar file for submission on Blackboard.

Test files (Right-click - save link as)
small.html - 22K
large.html - 279K (optional)

Tutorial on tcpdump & wireshark (02/08/2010)

Tutorial on DNS & DHCP (02/24/2010)

Last updated: Thu Oct 10 11:00:01 -0400 2013