]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1983, 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
a9cd9cb7 | 4 | .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) |
fea681da MK |
5 | .\" Redistribution and use in source and binary forms, with or without |
6 | .\" modification, are permitted provided that the following conditions | |
7 | .\" are met: | |
8 | .\" 1. Redistributions of source code must retain the above copyright | |
9 | .\" notice, this list of conditions and the following disclaimer. | |
10 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer in the | |
12 | .\" documentation and/or other materials provided with the distribution. | |
13 | .\" 3. All advertising materials mentioning features or use of this software | |
14 | .\" must display the following acknowledgement: | |
15 | .\" This product includes software developed by the University of | |
16 | .\" California, Berkeley and its contributors. | |
17 | .\" 4. Neither the name of the University nor the names of its contributors | |
18 | .\" may be used to endorse or promote products derived from this software | |
19 | .\" without specific prior written permission. | |
20 | .\" | |
21 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | .\" SUCH DAMAGE. | |
8c9302dc | 32 | .\" %%%LICENSE_END |
fea681da MK |
33 | .\" |
34 | .\" @(#)socketpair.2 6.4 (Berkeley) 3/10/91 | |
35 | .\" | |
36 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
37 | .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com> | |
c11b1abf MK |
38 | .\" Modified 2002-07-22 by Michael Kerrisk <mtk.manpages@gmail.com> |
39 | .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com> | |
0cc9687d | 40 | .\" 2008-10-11, mtk: Add description of SOCK_NONBLOCK and SOCK_CLOEXEC |
fea681da | 41 | .\" |
29b41e74 | 42 | .TH SOCKETPAIR 2 2015-12-28 "Linux" "Linux Programmer's Manual" |
fea681da MK |
43 | .SH NAME |
44 | socketpair \- create a pair of connected sockets | |
45 | .SH SYNOPSIS | |
53a6b01d | 46 | .BR "#include <sys/types.h>" " /* See NOTES */" |
fea681da MK |
47 | .br |
48 | .B #include <sys/socket.h> | |
49 | .sp | |
2269e870 MK |
50 | .BI "int socketpair(int " domain ", int " type ", int " protocol \ |
51 | ", int " sv [2]); | |
fea681da MK |
52 | .SH DESCRIPTION |
53 | The | |
31e9a9ec | 54 | .BR socketpair () |
2269e870 MK |
55 | call creates an unnamed pair of connected sockets in the specified |
56 | .IR domain , | |
fea681da MK |
57 | of the specified |
58 | .IR type , | |
59 | and using the optionally specified | |
60 | .IR protocol . | |
2269e870 MK |
61 | For further details of these arguments, see |
62 | .BR socket (2). | |
63 | ||
d9cb0d7d | 64 | The file descriptors used in referencing the new sockets are returned in |
fea681da MK |
65 | .IR sv [0] |
66 | and | |
67 | .IR sv [1]. | |
68 | The two sockets are indistinguishable. | |
47297adb | 69 | .SH RETURN VALUE |
c13182ef MK |
70 | On success, zero is returned. |
71 | On error, \-1 is returned, and | |
fea681da MK |
72 | .I errno |
73 | is set appropriately. | |
74 | .SH ERRORS | |
75 | .TP | |
76 | .B EAFNOSUPPORT | |
77 | The specified address family is not supported on this machine. | |
78 | .TP | |
79 | .B EFAULT | |
80 | The address | |
81 | .I sv | |
82 | does not specify a valid part of the process address space. | |
83 | .TP | |
84 | .B EMFILE | |
26c32fab | 85 | The per-process limit on the number of open file descriptors has been reached. |
fea681da MK |
86 | .TP |
87 | .B ENFILE | |
e258766b | 88 | The system-wide limit on the total number of open files has been reached. |
fea681da MK |
89 | .TP |
90 | .B EOPNOTSUPP | |
91 | The specified protocol does not support creation of socket pairs. | |
92 | .TP | |
93 | .B EPROTONOSUPPORT | |
94 | The specified protocol is not supported on this machine. | |
47297adb | 95 | .SH CONFORMING TO |
9fe752d0 | 96 | POSIX.1-2001, POSIX.1-2008, 4.4BSD. |
e511ffb6 | 97 | .BR socketpair () |
8e9b2765 | 98 | first appeared in 4.2BSD. |
1c44bd5b | 99 | It is generally portable to/from |
fea681da | 100 | non-BSD systems supporting clones of the BSD socket layer (including |
efbfd7ec | 101 | System\ V variants). |
fea681da | 102 | .SH NOTES |
c13182ef | 103 | On Linux, the only supported domain for this call is |
0daa9e92 | 104 | .B AF_UNIX |
fea681da MK |
105 | (or synonymously, |
106 | .BR AF_LOCAL ). | |
107 | (Most implementations have the same restriction.) | |
53a6b01d | 108 | |
0cc9687d MK |
109 | Since Linux 2.6.27, |
110 | .BR socketpair () | |
111 | supports the | |
112 | .BR SOCK_NONBLOCK | |
113 | and | |
114 | .BR SOCK_CLOEXEC | |
57f8da4c MK |
115 | flags in the |
116 | .I type | |
117 | argument, as described in | |
0cc9687d MK |
118 | .BR socket (2). |
119 | ||
9fe752d0 | 120 | POSIX.1 does not require the inclusion of |
53a6b01d MK |
121 | .IR <sys/types.h> , |
122 | and this header file is not required on Linux. | |
123 | However, some historical (BSD) implementations required this header | |
124 | file, and portable applications are probably wise to include it. | |
47297adb | 125 | .SH SEE ALSO |
fea681da MK |
126 | .BR pipe (2), |
127 | .BR read (2), | |
128 | .BR socket (2), | |
129 | .BR write (2), | |
5dfedcae | 130 | .BR socket (7), |
fea681da | 131 | .BR unix (7) |