Exercises


4.1

In Section 4.4, we stated that the INADDR_ constants defined by the <netinet/in.h> header are in host byte order. How can we tell this?

4.2

Modify Figure 1.5 to call getsockname after connect returns successfully. Print the local IP address and local port assigned to the TCP socket using sock_ntop . In what range (Figure 2.10) are your system's ephemeral ports?

4.3

In a concurrent server, assume the child runs first after the call to fork . The child then completes the service of the client before the call to fork returns to the parent. What happens in the two calls to close in Figure 4.13?

4.4

In Figure 4.11, first change the server's port from 13 to 9999 (so that we do not need super- user privileges to start the program). Remove the call to listen . What happens?

4.5

Continue the previous exercise. Remove the call to bind , but allow the call to listen . What happens?




UNIX Network Programming Volume 1, Third Edition
Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)
ISBN: 0131411551
EAN: 2147483647
Year: 2003
Pages: 441

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net