ptg10805159
628 Network IPC: Sockets Chapter 16
16.9 Summary
In this chapter, we looked at the IPC mechanisms that allow processes to communicate
with other processes on different machines as well as within the same machine. We
discussed how socket endpoints arenamed and how we can discover the addresses to
use when contacting servers.
We presented examples of clients and servers that use connectionless (i.e.,
datagram-based) sockets and connection-oriented sockets. We briefly discussed
asynchronous and nonblocking socket I/O and the interfaces used to manage socket
options.
In the next chapter, we will look at some advanced IPC topics, including how we
can use sockets to pass file descriptors between processes running on the same machine.
Exercises
16.1 Write a program to determine your system’s byte ordering.
16.2 Write a program to print out whichstatstructuremembers aresupported for sockets on
at least two different platforms, and describe how the results differ.
16.3 The program in Figure16.17 provides service on only a single endpoint. Modify the
program to support service on multiple endpoints (each with a different address) at the
same time.
16.4 Write a client program and a server program to return the number of processes currently
running on a specified host computer.
16.5 In the program in Figure16.18, the server waits for the child to execute theuptime
command and exit beforeaccepting the next connect request. Redesign the server so that
the time to service one request doesn’t delay the processing of incoming connect requests.
16.6 Write two library routines: one to enable asynchronous (signal-based) I/O on a socket and
one to disable asynchronous I/O on a socket. Use Figure16.23 to make surethat the
functions work on all platforms with as many socket types as possible.