Programming with sockets

Please work out the pre-lab problems before your next lab section. The GSI/IAs will go over all problems during the lab section.

[pre-lab and in-lab] 1. Socket Programming

You will use sockets in Project 4 to facilitate communication between a client and the network file server you will write. This exercise will serve to give you practice using the various socket functions for both the client and the server.

[pre-lab] A. Read the socket programming tutorial on the course webpage.

[pre-lab] B. Write a simple client and server, where the client sends a string to the server, the server outputs the string using cout, and then sends some acknowledgement response back to the client.

Use TCP by specifying options AF_INET and SOCK_STREAM when calling socket(). Use send() in the client to send data, and recv() in the server to receive it.

[in-lab] C. Run your client and server on a CAEN machine (the client and server programs need to run on the same CAEN machine, since the CAEN firewall won't let you communicate between machines). Then try communicating with another student in your section.