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/types.h>          /* See NOTES */
10       #include <sys/socket.h>
11
12       int socketpair(int domain, int type, int protocol, int sv[2]);
13

DESCRIPTION

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

RETURN VALUE

24       On  success,  zero is returned.  On error, -1 is returned, and errno is
25       set appropriately.
26

ERRORS

28       EAFNOSUPPORT
29              The specified address family is not supported on this machine.
30
31       EFAULT The address sv does not specify a  valid  part  of  the  process
32              address space.
33
34       EMFILE Too many descriptors are in use by this process.
35
36       ENFILE The  system  limit  on  the  total number of open files has been
37              reached.
38
39       EOPNOTSUPP
40              The specified protocol  does  not  support  creation  of  socket
41              pairs.
42
43       EPROTONOSUPPORT
44              The specified protocol is not supported on this machine.
45

CONFORMING TO

47       4.4BSD,  POSIX.1-2001.   The  socketpair()  function  call  appeared in
48       4.2BSD.  It is generally portable to/from  non-BSD  systems  supporting
49       clones of the BSD socket layer (including System V variants).
50

NOTES

52       On  Linux,  the only supported domain for this call is AF_UNIX (or syn‐
53       onymously, AF_LOCAL).  (Most implementations  have  the  same  restric‐
54       tion.)
55
56       Since   Linux  2.6.27,  socketpair()  supports  the  SOCK_NONBLOCK  and
57       SOCK_CLOEXEC flags described in socket(2).
58
59       POSIX.1-2001 does not require the inclusion of <sys/types.h>, and  this
60       header  file  is not required on Linux.  However, some historical (BSD)
61       implementations required this header file,  and  portable  applications
62       are probably wise to include it.
63

SEE ALSO

65       pipe(2), read(2), socket(2), write(2), socket(7), unix(7)
66

COLOPHON

68       This  page  is  part of release 3.53 of the Linux man-pages project.  A
69       description of the project, and information about reporting  bugs,  can
70       be found at http://www.kernel.org/doc/man-pages/.
71
72
73
74Linux                             2008-10-11                     SOCKETPAIR(2)
Impressum