ptg10805159
16
Networ k IPC: Sockets
16.1 Introduction
In the previous chapter, we looked at pipes, FIFOs, message queues, semaphores, and
shared memory—the classical methods of IPC provided by various UNIX systems.
These mechanisms allow processes running on the same computer to communicate
with one another.Inthis chapter, we look at the mechanisms that allow processes
running on different computers (connected to a common network) to communicate with
one another—network IPC.
In this chapter, we describe the socket network IPC interface, which can be used by
processes to communicate with other processes, regardless of wherethey are
running — on the same machine or on different machines. Indeed, this was one of the
design goals of the socket interface. The same interfaces can be used for both
intermachine communication and intramachine communication. Although the socket
interface can be used to communicate using many different network protocols, we will
restrict our discussion to the TCP/IP protocol suite in this chapter,since it is the de facto
standardfor communicating over the Internet.
The socket API as specified by POSIX.1 is based on the 4.4BSD socket interface.
Although minor changes have been made over the years, the current socket interface
closely resembles the interface when it was originally introduced in 4.2BSD in the early
1980s.
This chapter is only an overview of the socket API. Stevens, Fenner,and Rudoff
[ 2004 ] discuss the socket interface in detail in the definitive text on network
programming in the UNIX System.
589