Assignment 3

This is an individual assignment. Each of you have to submit both hard copy and electronic copy of your assignment. The hard copy must have a cover sheet. Students are encouraged to discuss the problems in the assignment together, but you are not allowed to show your answers to the other students.
  1. Draw a state transition diagram similar to Figure 2.5 in Stevens's text to show a scenario where both the server and the client enter the TIME_WAIT state from the original CLOSED state. (If you have some difficulty in drawing the diagram with a computer, you can just draw it on a piece of paper and attach this paper to your hard copy submission).

  2. Read Section 6.6 of Stevens' text and answer the following questions:
    1. Compare the difference of the following two operations on an open socket sock:
          close (sock);
          shutdown (sock, SHUT_RDWR); 
    2. Modify the daytime server and client programs in the following way:
      • the client sleeps for 1 second after connect returns, and calls shutdown on the socket with SHUT_RD as the value of the second parameter. After that the client tries to get data from the server until read returns 0.
      • the server writes a date string to the client after acceptreturns, and sleeps for 5 seconds, and then write the same date string to the client.

      Observe the result and compare the result with the description for SHUT_RD on Page 160 of Stevens' text.

  3. Describe the process to elicit a SIG_PIPE signal from the write operation on an open socket in detail. Write a snippet of code to prevent your program from terminating for this signal.

  4. From the client's point of view describe the difference between the cases where the server program crashed and the case where the server host crashed.

  5. Read Section 2.5 and 2.6 of Stevens' text and explain the reasons why a socket should be in the TIME_WAIT state for 2 MSL time.

  6. Function select is used to test if an open socket is ready for reading or writing. Answer the following questions about this function:

  7. Read Section 20.4 of Stenvens' text and give a strategy to choose whether you should use TCP or UDP for a specific application.

  8. Another way to handle multiple clients concurrently is to use non-blocking sockets. Describe your implementation to let the server serve multiple clients without using multiplexing functions, such as select and poll.

Note:
Hosted by www.Geocities.ws

1