DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Interprocess communication using UNIX domain sockets

Socket Tutorial (UNIX domain)

This section focuses on how to apply the concepts discussed in the first half of the chapter. The focus of the discussion is primarily on connection-oriented streams sockets, although some reference is made to connectionless datagram sockets. The section concludes with example programs using streams sockets, datagram sockets, and socketpairs. The client and server examples for streams sockets are annotated.

The Sockets Library (SLIB) provides an application program interface (API) for communication between processes. For the UNIX domain, the processes must be executing on the same system; for the Internet domain, the processes can communicate across a network protocol. Sockets are bidirectional, providing a two-way flow of data between processes that may or may not have the same parent.

Pipes provide a similar functionality. However, they are unidirectional, and they can be used only between processes that have the same parent. This also implies that the two processes must be executing on the same host. To obtain a bidirectional flow of data with pipes, the pipe(S) system call must be executed twice, returning four file descriptors. Communication between processes in a distributed environment should not depend on whether the processes are on the same machine. Unlike pipes, a connected socket returns a pair of socket descriptors, not file descriptors. Socket descriptors are assigned by the kernel with the accept(SSC) and socket(SSC) system calls.


Next topic: Creating a socket (UNIX domain)
Previous topic: List of error codes

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003