CSE 333 24su Exercise 16

Due: Wednesday, August 7th, 2024 by 10:00 am; No late exercises accepted.
Goals:Write a server that accepts TCP connections from a client computer and exchange data with it.

Description: Write the server to go along with ex15. More specifically, write a C++ program called ex16 that accepts one command line argument: a port number to listen to.

The program should create a TCP listening socket on the supplied port number. Once a client connects, the program should read data from the connected client socket and write it to stdout until there is no more data to read from the client (i.e., until EOF or a socket error occurs). Once all of the data has been read and written, the program should close the client socket and the listening socket, and then exit.

To test your program, try running it on a specific attu machine, say attu4.cs.washington.edu, and use your ex15 binary to send it a file. For example, on attu4.cs.washington.edu, run the following command:

./ex16 5555 > output.bytes

Then, on some client machine, pick a file to send to your server. For example, this command will send the ex15 binary to the server (assuming that the server is running on attu4):

./ex15 attu4.cs.washington.edu 5555 ex15

Once the file has transferred, you should use md5sum to verify that the file was sent correctly. For example, on the server, run this:

md5sum output.bytes

and on the client, run this:

md5sum ex15
and you should see the same MD5 signature printed out on both ends.

There are a few requirements on your code:

As with the previous exercise, feel free to adapt sample code from lecture and section as part of your solution if it helps, but be sure you understand what your code does when you're done.


As usual, your code must:

You should submit your exercise to the course Gradescope.