Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.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
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/socket.h>
int socketpair(
int domain,
int type,
int protocol,
int socket_vector[2]
);
PARAMETERS
domain Specifies the communications domain in which the sockets are created. This
parameter must be set to AF_UNIX.
type Specifies the type of sockets to create.
protocol Specifies 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 Specifies a 2-integer array used to hold the file descriptors of the socket pair
created with this function call.
DESCRIPTION
The socketpair() function creates an unbound pair of connected sockets in the domain specified
by the domain parameter, of the type specified by the type parameter, under the protocol option-
ally specified by the protocol parameter.
The two sockets created by the socketpair() function are identical. The file descriptors for the
socket pair are returned in socket_vector[0] and socket_vector[1].
The domain parameter specifies 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 specifies 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 fixed
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 specific address families specifies which socket types each family sup-
ports. The sys/socket.h header file contains definitions 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 defined in the sys/socket.h file.
527186-023 Hewlett-Packard Company 7−119