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 sent by the client. You must implement a function in your server side to read message line by line (not to read the message from the client in one single TCP read). 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 line by line 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.
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.
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% |
| 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:
How well we can understand your code. There is no required format for your code, there is no requirement like "you must have one comment for every 5 lines of code". Feel free to provide whatever level of commenting you believe is appropriate to make sure that other competent programmers could easily understand and make changes to your code.
All project files must be submitted via handin command on any Unix machine in the department as follows:
> handin.360.2 3 file1 file2 file3 ...
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 hw3.tgz file1 file2 file3 ...
and submit the single zip file hw3.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 hw3.tgz
Don't send compiled code! Please ask question if you don't understand any part of this project.