ptg10805159
17
Advanced IPC
17.1 Introduction
In the previous two chapters, we discussed various forms of IPC, including pipes and
sockets. In this chapter, we look at an advanced form of IPC—the UNIX domain socket
mechanism — and see what we can do with it.With this form of IPC, we can pass open
file descriptors between processes running on the same computer system, server
processes can associate names with their file descriptors, and client processes running
on the same system can use these names to rendezvous with the servers.We’ll also see
how the operating system provides a unique IPC channel per client.
17.2 UNIX Domain Sockets
UNIX domain sockets areused to communicate with processes running on the same
machine. Although Internet domain sockets can be used for this same purpose, UNIX
domain sockets aremoreefficient. UNIX domain sockets only copy data; they have no
protocol processing to perform, no network headers to add or remove, no checksums to
calculate, no sequence numbers to generate, and no acknowledgements to send.
UNIX domain sockets provide both stream and datagram interfaces. The UNIX
domain datagram service is reliable, however.Messages areneither lost nor delivered
out of order.UNIX domain sockets arelike a cross between sockets and pipes.Youcan
use the network-oriented socket interfaces with them, or you can use thesocketpair
function to create a pair of unnamed, connected, UNIX domain sockets.
629