Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)

1.1

Go through the steps at the end of Section 1.9 to discover information about your network topology.

1.2

Obtain the source code for the examples in this text (see the Preface). Compile and test the TCP daytime client in Figure 1.5. Run the program a few times, specifying a different IP address as the command-line argument each time.

1.3

Modify the first argument to socket in Figure 1.5 to be 9999. Compile and run the program. What happens? Find the errno value corresponding to the error that is printed. How can you find more information on this error?

1.4

Modify Figure 1.5 by placing a counter in the while loop, counting the number of times read returns a value greater than 0. Print the value of the counter before terminating. Compile and run your new client.

1.5

Modify Figure 1.9 as follows : First, change the port number assigned to the sin_port member from 13 to 9999. Next, change the single call to write into a loop that calls write for each byte of the result string. Compile this modified server and start it running in the background. Next, modify the client from the previous exercise (which prints the counter before terminating), changing the port number assigned to the sin_port member from 13 to 9999. Start this client, specifying the IP address of the host on which the modified server is running as the command-line argument. What value is printed as the client's counter? If possible, also try to run the client and server on different hosts .

Категории