1SOCKETPAIR(2)              Linux Programmer's Manual             SOCKETPAIR(2)
2
3
4

NAME

6       socketpair - create a pair of connected sockets
7

SYNOPSIS

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

DESCRIPTION

14       The  socketpair()  call creates an unnamed pair of connected sockets in
15       the specified domain, of the specified type, and using  the  optionally
16       specified  protocol.   For  further  details  of  these  arguments, see
17       socket(2).
18
19       The file descriptors used in referencing the new sockets  are  returned
20       in sv[0] and sv[1].  The two sockets are indistinguishable.
21

RETURN VALUE

23       On  success,  zero is returned.  On error, -1 is returned, errno is set
24       to indicate the error, and sv is left unchanged
25
26       On Linux (and other systems), socketpair() does not modify sv on  fail‐
27       ure.    A   requirement   standardizing  this  behavior  was  added  in
28       POSIX.1-2008 TC2.
29

ERRORS

31       EAFNOSUPPORT
32              The specified address family is not supported on this machine.
33
34       EFAULT The address sv does not specify a valid part of the process  ad‐
35              dress space.
36
37       EMFILE The per-process limit on the number of open file descriptors has
38              been reached.
39
40       ENFILE The system-wide limit on the total number of open files has been
41              reached.
42
43       EOPNOTSUPP
44              The  specified  protocol  does  not  support  creation of socket
45              pairs.
46
47       EPROTONOSUPPORT
48              The specified protocol is not supported on this machine.
49

CONFORMING TO

51       POSIX.1-2001, POSIX.1-2008, 4.4BSD.   socketpair()  first  appeared  in
52       4.2BSD.   It  is  generally portable to/from non-BSD systems supporting
53       clones of the BSD socket layer (including System V variants).
54

NOTES

56       On Linux, the only supported domains for this call are AF_UNIX (or syn‐
57       onymously, AF_LOCAL) and AF_TIPC (since Linux 4.12).
58
59       Since   Linux  2.6.27,  socketpair()  supports  the  SOCK_NONBLOCK  and
60       SOCK_CLOEXEC flags in the type argument, as described in socket(2).
61

SEE ALSO

63       pipe(2), read(2), socket(2), write(2), socket(7), unix(7)
64

COLOPHON

66       This page is part of release 5.12 of the Linux  man-pages  project.   A
67       description  of  the project, information about reporting bugs, and the
68       latest    version    of    this    page,    can     be     found     at
69       https://www.kernel.org/doc/man-pages/.
70
71
72
73Linux                             2021-03-22                     SOCKETPAIR(2)
Impressum