Chapter Questions
Download the example client and server from comerbooks.com and run them on your local system.
Build a simple server that accepts multiple concurrent TCP connections. To test your server, have the process that handles a connection print a short message, delay a random time, print another message, and exit.
When is the listen call important?
What functions does your local system provide to access the Domain Name System?
Devise a server that uses a single Linux process (i.e., a single thread of execution), but handles multiple concurrent TCP connections. (Hint: think of select.)
Read about alternatives to the socket interface, such as the Transport Library Interface (TLI) and compare them to sockets. What are the major conceptual differences?
Each operating system limits the number of sockets a given program can use at any time. How many sockets can a program create on your local system?
Can the socket/file descriptor mechanism and associated read and write operations be considered a form of object-oriented design? Explain why or why not.
Consider an alternative API design that provides an interface for each layer of protocol software (e.g., the API allows an application program to send and receive raw frames without using IP, or to send and receive IP datagrams without using UDP or TCP). What are the advantages of having such an interface? The disadvantages?
A client and server can both run on the same computer and use a TCP socket to communicate. Explain how it is possible to build a client and server that can communicate on a single machine without learning the host's IP address.
Experiment with the sample server in this chapter to see if you can generate TCP connections sufficiently fast to exceed the backlog the server specifies. Do you expect incoming connection requests to exceed the backlog faster if the server operates on a computer that has one core than on a computer that has four cores? Explain.
Some of the functions in the original socket API are now irrelevant. Make a list of socket functions that are no longer useful.
Read more about IPv6 address scope. If a server binds a socket to an address with linklocal scope, which computers can contact the server?
If a programmer wants to create a server that can be reached either via IPv4 or IPv6, what socket functions should the programmer use and how should addresses be specified?