SOCKETPAIR(2)

NAME
socketpair - creates a pair of connected sockets.

SYNOPSIS
#include <sys/socket.h>
int socketpair(int domain, int type, int protocol, int sv[2]);

DESCRIPTION
socketpair() creates two connected sockets of the specified type in the specified domain using the specified protocol and stores the two resulting socket descriptors in sv[2].

RETURN VALUES
On success, this function returns 0, and sv[2] is set to the two newly created socket descriptors. On error, -1 is returned and errno is set.

ERRORS

[EAFNOSUPPORT]
    The domain is not supported.

[EPROTOTYPE]
    The protocol is not supported by the domain.

[EPROTONOSUPPORT]
    The protocol is not supported by the type.

[EINVAL]
    The pair of sockets aren't in a valid state or are not connection oriented sockets.

[EPERM]
    The user ID, group ID, and process ID of the first socket doesn't match that of the second.

NOTES
This function is only implemented for unix domain sockets. Therefore, the only valid value for domain is AF_UNIX

SEE ALSO
socket(2), unix(8)

HISTORY
This function first appeared in Minix 3.1.8.