socketpair(3)

NAME
socketpair - create a pair of connected sockets

SYNOPSIS
#include <sys/socket.h>

int socketpair(int af, int type, int protocol, int sv[2]);

DESCRIPTION
socketpair creates an unnamed pair of connected sockets and returns two file descriptors in sv[0] and sv[1]. The two sockets are indistinguishable. af specifies the address family. See socket(3). type specifies the semantics of communication for the socket. protocol specifies a particular protocol to be used. protocol can be supplied as zero, in which case the system chooses a protocol type to use.

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.

DIAGNOSTICS
The socketpair call fails if :

    [ENOENT]
        The socket device driver has not been started.

    [EMFILE]
        The per-process file descriptor table is full.

    [EAFNOSUPPORT]
        The specified address family is not supported.

    [ESOCKTNOSUPPORT]
        The specified socket type is not supported in this address family.

    [EPROTONOSUPPORT]
        The specified protocol is not supported.

    [EOPNOSUPPORT]
        The specified protocol does not support creation of socket pairs.

    [ENOMEM]
        Insufficient resources were available in the system to perform the operation.

    [EPROTOTYPE]
        The type of socket and protocol do not match.

DEPENDENCIES
This call is supported only for AF_UNIX.

SEE ALSO
read(3), write(3), socket(3).