Lab 11: The Unix Socket Protocol

In this lab, you will write a simple client / server program. You will be required to submit the code you wrote and a report answering a few questions.

Lab Materials
  1. Slides
  2. Lab files
Assignment
Complete the client / server program in client.c and server.c. This simple program should send the array of strings hard coded in the client process to the server process, which should convert them to uppercase, and send them back to the client. Use printf statements to narrate the flow of this program.

To build your program, open a terminal and type:
  bash$ make
To test your program, first, run your server process:
  bash$ ./server
Leave the server running, open another terminal, and run the client process:
  bash$ ./client
A correct implementation should give the following output. From the server process:
  bash$ ./server 
  RECEIVED:
  this is the first string from the client
  SENDING:
  THIS IS THE FIRST STRING FROM THE CLIENT
  
  RECEIVED:
  this is the second string from the client
  SENDING:
  THIS IS THE SECOND STRING FROM THE CLIENT
  
  RECEIVED:
  this is the third string from the client
  SENDING:
  THIS IS THE THIRD STRING FROM THE CLIENT
	  
And from the client process:
  bash$ ./client 
  SENDING:
  this is the first string from the client
  RECEIVED:
  THIS IS THE FIRST STRING FROM THE CLIENT
  
  SENDING:
  this is the second string from the client
  RECEIVED:
  THIS IS THE SECOND STRING FROM THE CLIENT
  
  SENDING:
  this is the third string from the client
  RECEIVED:
  THIS IS THE THIRD STRING FROM THE CLIENT
	  


After you have finished your implementation, you need to complete a short report that answers the following questions:
  1. Briefly describe the design of the program. How does your program control when the client runs and when the server runs?
  2. What is the purpose of the handshake socket? Why not have the server create and bind session sockets that clients may connect to directly?
  3. For the simple / client server program, we chose to use sockets instead of pipes to send messages between the client and server. Why are sockets preferred over pipes for this program? Give at least two reasons.
Submission

Once you are done with the lab, Modify the Makefile as per your student ID and use the zip target to create an archive for submission on blackboard.


< Back to the Lab Home Page