A socket pair consists of a pair of connected (but unnamed)
sockets. It is very similar to a pipe and is used in much the same
way. Socket pairs are created with the
declared in `sys/socket.h'. A socket pair is much like a pipe; the
main difference is that the socket pair is bidirectional, whereas the
pipe has one input-only end and one output-only end (see section Pipes and FIFOs).
filedes. The socket pair is a full-duplex communications channel, so that both reading and writing may be performed at either end.
The namespace, style, and protocol arguments are
interpreted as for the
socket function. style should be
one of the communication styles listed in section Communication Styles.
The namespace argument specifies the namespace, which must be
AF_FILE (see section The File Namespace); protocol specifies the
communications protocol, but zero is the only meaningful value.
If style specifies a connectionless communication style, then the two sockets you get are not connected, strictly speaking, but each of them knows the other as the default destination address, so they can send packets to each other.
socketpair function returns
0 on success and
on failure. The following
errno error conditions are defined
for this function:
Go to the first, previous, next, last section, table of contents.