You are required to submit code, which compiles and runs on the FC 010 machines. Emphasis is on the correctness of the code (buffer management, handling return values), system calls and their arguments. Both programs should be written in C or C++. You should also include a makefile for compiling your programs, and submit a gzipped tar file (with the .tgz extension) including your client, server, and makefile, via the DropBox site for this assignment.
Grading: This assignment will count towards your participation grade.
We want you to write a server capable of receiving text messages from clients over TCP sockets. The server should print these text messages on the standard output. From the server perspective, the 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 on a port known to the clients. It should handle the client connections sequentially and accept connections from multiple clients. After servicing one client to completion, it should proceed to the next. If multiple clients try to simultaneously send text messages to the server, the server should handle them one at a time (in any order). Serving one client at a time is enough.
We also want you to write a client. The client should read from a file -- either one named "filein.txt" that can be hardcoded in your source code, or from stdin -- then transmit the message and exit.
You can assume that the client is run as
$ ./client server-IP-address port-numberwhere "server-IP-address" is the IP address of the server, and "port-number" is the TCP port the server listens on. The server is run as "server port-number". If the server cannot bind on a port, print a message to standard error.
The FC Lab machines firewalls low ports, so you should only use a port greater than 10000 and less than 60000 while testing.
You should use fread and fwrite calls for reading/writing data to and from sockets and files. Do not use special "string" versions of these calls (e.g., fgets and fputs as they are not designed for binary data).
Make sure you handle the following correctly:
Last updated: Sun Feb 17 10:28:01 -0500 2013