socketpair()

create a pair of connected sockets

Synopsis:

#include <sys/types.h>
#include <sys/socket.h>

int socketpair( int d, 
                int type, 
                int protocol, 
                int *sv );

Description:

The socketpair() call creates an unnamed pair of connected sockets in the specified domain d, of the specified type, using the optionally specified protocol. The descriptors used in referencing the new sockets are returned in sv[0] and sv[1]. The two sockets are indistinguishable.

Returns:

0
Success.
-1
An error occurred. errno is set.

Errors:

If an error occurred, errno could contain one of the following:

EAFNOSUPPORT
The specified address family isn't supported on this machine.
EFAULT
The address sv doesn't specify a valid part of the process address space.
EMFILE
Too many descriptors are in use by this process.
EOPNOTSUPP
The specified protocol doesn't support creation of socket pairs.
EPROTONOSUPPORT
The specified protocol isn't supported on this machine.

Classification:

UNIX

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

read(), write(), pipe() in the C Library Reference