Description
This project is to write simple TCP client and Server in C or C++. Your programs should have the following functions:
TCP Server
Your server creates a passive mode TCP socket and waits for client connections at a specified port. Below is an example of a command line that could be used to run your TCP server on port 1234:
./tcpserver 1234
When a new connection is established, the server reads ASCII data line by line sent by the client. The server then reverses the order of characters in each line and writes it to standard output. Your server should quit when the client finishes sending.
TCP Client
Your client connects to the TCP server at the specified port. After successfully connecting to the server, the client reads data from an ASCII file and sends to the TCP server. The client closes the connection after finishing sending the file. Below is an example of a command line that could be used to run your TCP client on port 1234 and communicate with the server at address 130.127.45.7:
./tcpclient 130.127.45.7 1234 myfile
The first command line parameter must be the server’s IP address. The port number in the client program should be the same as the port number in the server program. “myfile” is the name of the ASCII file.
What is required:
- Your server and client must use the same port number specified in the command line.
- Your client should read from the file specified in the third command line parameter (argv[3]).
- Your client must send the file line by line. You can not send the file at once or character by character.
- Your client should close the connection after finishing sending the file.
- Your server must read the data line by line, and reverse the order of characters in each line and output the reversed lines to the terminal.
- Your server must quit when client closes the connection.
Deliverables
You must submit all the source code necessary for us to build and test your TCP client and server. You must also include Makefile that can be used to build your client and server on the CS Sun workstations. If you don’t know how to use make or create a Makefile, refer to the sample TCP client and server code. Feel free to ask for help in creating a Makefile.
You must also include in your submission a file named README
that includes your name and a brief description of your submission, including the name of each file submitted along with a one line description of what is in the file. If your code is not complete, tell us what works and what doesn’t. If you are submitting code that does not compile, please tell us that as well. If any of your code was written by someone else, you are required to tell us about it (this must also be documented in the code itself). Finally, feel free to include a description of any problems you had or anything else you think might be helpful to us.
Grading
Your project will be tested to make sure it works properly. Here is a rough breakdown of the grading:
TCP Server | 40% |
TCP Client | 40% |
Submission, Error handling, Style/Code structure, etc. | 20% |
NOTE: 20% of your homework grade depends on the how “well your code is written”. These points include the following:
- Error handling (check every system call for an error!).
- Safe code (avoiding buffer overflow, etc).
- How well we can understand your code. There is no required format for your code. However, providing appropriate commends is needed to make sure that other competent programmers could easily understand and make changes to your code.
Submitting your files
All projects must be submitted via handin: https://handin.cs.clemson.edu
Please make sure you submit all your source files not the object files. You can also zip the files using the following command first:
> tar cvzf hw2.tgz file1 file2 file3 …
and submit the single zip file hw2.tgz. Before you submit this single file, please use the following command to check make sure you have everything in this zip file:
> tar tvzf hw2.tgz
Don’t send compiled code! Please ask question if you don’t understand any part of this project.