Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (s and S) socketpair(2)
NAME
socketpair - Creates a pair of connected sockets
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/socket.h>
int socketpair(
int domain,
int type,
int protocol,
int socket_vector[2]
);
PARAMETERS
domain Species the communications domain in which the sockets are created. This
parameter must be set to AF_UNIX.
type Species the type of sockets to create.
protocol Species the communications protocol that the socket pair will use. Specifying a
value of 0 (zero) for this parameter causes the socketpair() function to default to
the typical protocol used for the requested socket type.
socket_vector Species a 2-integer array used to hold the le descriptors of the socket pair
created with this function call.
DESCRIPTION
The socketpair() function creates an unbound pair of connected sockets in the domain specied
by the domain parameter, of the type specied by the type parameter, under the protocol option-
ally specied by the protocol parameter.
The two sockets created by the socketpair() function are identical. The le descriptors for the
socket pair are returned in socket_vector[0] and socket_vector[1].
The domain parameter species the address family used in the communications domain. The
socketpair() function supports only the AF_UNIX address family, which supports the use of
UNIX pathnames.
The type parameter species the socket type, which determines the communication semantics
that the socket pair will use. The socket types supported are:
SOCK_DGRAM
Provides datagrams, which are connectionless, unreliable messages of a xed
maximum length.
SOCK_STREAM
Provides sequenced, reliable, two-way, connection-oriented byte streams with a
transmission mechanism for out-of-band data.
The documentation for specic address families species which socket types each family sup-
ports. The sys/socket.h header le contains denitions for socket domains, types, and protocols.
Socket-level options control socket operations. The getsockopt() and setsockopt() functions are
used to get and set these options, which are dened in the sys/socket.h le.
527186-003 Hewlett-Packard Company 775