CSE 333 24su Exercise 15

Due: Monday, August 5th, 2024 by 10:00 am; No late exercises accepted. Goals: Create a program that uses TCP sockets to connect to a server and exchange data with it.

Description: Write a C++ program that accepts three command line arguments:

The program should connect (via TCP) to the server on the supplied hostname and port. Once connected, the program should read the bytes from the local file, and it should write those bytes over the TCP connection. Once all of the bytes have been written, the program should close the TCP connection and exit.

To test your program, you can run a server using the nc program. For example, to run the server on port 5555, and to have the server redirect the incoming bytes to file output.bytes, run the following command:

nc -l 5555 > output.bytes
Note that nc will exit once it has processed a single connection, so you'll need to rerun nc each time you test your client.

If you are running nc on the same computer/host where you are running your ex15 code, you can use the special loop-back IP address 127.0.0.1 to refer to the same local host. Please note that each attu (e.g. attu1, attu2, etc.) is a separate machine with its own IP addresses, so if you are running on attu you can only reliably use 127.0.0.1 if both client and server are running on the same actual machine.

There are a few requirements on your code:

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.