socketpair(2) CLIX socketpair(2)
NAME
socketpair - Creates a pair of connected sockets
LIBRARY
Berkeley Software Distribution Library (libbsd.a)
SYNOPSIS
int socketpair(
int d ,
int type ,
int protocol ,
int sv[2] );
PARAMETERS
d Represents a communications domain.
type Specifies the communication semantics.
protocol Represents the protocol associated with these sockets.
sv Specifies a buffer used to hold the identifiers of the new
sockets.
DESCRIPTION
The socketpair() function creates an unnamed pair of connected sockets in
the specified domain d, of the specified type type, and using the
optionally specified protocol protocol. (See the socket() function.) The
descriptors used in referencing the new sockets are returned in sv[0] and
sv[1]. The two sockets are indistinguishable.
EXAMPLES
To create a unix domain socket pair:
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)
perror("Socketpair failed");
NOTES
The socketpair() function is supported only in the UNIX domain.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise, a value
of -1 is returned and errno is set to indicate the error.
2/94 - Intergraph Corporation 1
socketpair(2) CLIX socketpair(2)
ERRORS
The socketpair() function fails if one or more of the following is true:
[EMFILE]
The per-process descriptor table is full.
[ENFILE]
The system file table is full.
[ENOBUFS]
The resources to support this connection are not available.
[EPROTONOSUPPORT]
The specified domain, type, or protocol is not supported.
[ESOCKTNOSUPPORT]
The socket type is not supported for the specified domain.
[ENXIO]
The system cannot access the specified device.
[EFAULT]
The address sv does not specify a valid part of the process address
space.
[EINTR]
A signal was caught during the socketpair() function.
RELATED INFORMATION
Functions: readv(2), writev(2), socket(2), pipe(2)
2 Intergraph Corporation - 2/94