]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1983, 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
47009d5e | 4 | .\" SPDX-License-Identifier: BSD-4-Clause-UC |
fea681da MK |
5 | .\" |
6 | .\" @(#)socketpair.2 6.4 (Berkeley) 3/10/91 | |
7 | .\" | |
8 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
9 | .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com> | |
c11b1abf MK |
10 | .\" Modified 2002-07-22 by Michael Kerrisk <mtk.manpages@gmail.com> |
11 | .\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com> | |
0cc9687d | 12 | .\" 2008-10-11, mtk: Add description of SOCK_NONBLOCK and SOCK_CLOEXEC |
fea681da | 13 | .\" |
4c1c5274 | 14 | .TH socketpair 2 (date) "Linux man-pages (unreleased)" |
fea681da MK |
15 | .SH NAME |
16 | socketpair \- create a pair of connected sockets | |
f8b3ad7f AC |
17 | .SH LIBRARY |
18 | Standard C library | |
8fc3b2cf | 19 | .RI ( libc ", " \-lc ) |
fea681da | 20 | .SH SYNOPSIS |
c7db92b9 | 21 | .nf |
fea681da | 22 | .B #include <sys/socket.h> |
68e4db0a | 23 | .PP |
2269e870 MK |
24 | .BI "int socketpair(int " domain ", int " type ", int " protocol \ |
25 | ", int " sv [2]); | |
c7db92b9 | 26 | .fi |
fea681da MK |
27 | .SH DESCRIPTION |
28 | The | |
31e9a9ec | 29 | .BR socketpair () |
2269e870 MK |
30 | call creates an unnamed pair of connected sockets in the specified |
31 | .IR domain , | |
fea681da MK |
32 | of the specified |
33 | .IR type , | |
34 | and using the optionally specified | |
35 | .IR protocol . | |
2269e870 MK |
36 | For further details of these arguments, see |
37 | .BR socket (2). | |
efeece04 | 38 | .PP |
d9cb0d7d | 39 | The file descriptors used in referencing the new sockets are returned in |
e7ff7535 | 40 | .I sv[0] |
fea681da | 41 | and |
e7ff7535 | 42 | .IR sv[1] . |
fea681da | 43 | The two sockets are indistinguishable. |
47297adb | 44 | .SH RETURN VALUE |
c13182ef | 45 | On success, zero is returned. |
1548a03a | 46 | On error, \-1 is returned, |
fea681da | 47 | .I errno |
c112329f | 48 | is set to indicate the error, and |
1548a03a MK |
49 | .I sv |
50 | is left unchanged | |
efeece04 | 51 | .PP |
53ee58a3 MK |
52 | On Linux (and other systems), |
53 | .BR socketpair () | |
54 | does not modify | |
55 | .I sv | |
56 | on failure. | |
5dbd04b5 | 57 | A requirement standardizing this behavior was added in POSIX.1-2008 TC2. |
53ee58a3 | 58 | .\" http://austingroupbugs.net/view.php?id=483 |
fea681da MK |
59 | .SH ERRORS |
60 | .TP | |
61 | .B EAFNOSUPPORT | |
62 | The specified address family is not supported on this machine. | |
63 | .TP | |
64 | .B EFAULT | |
65 | The address | |
66 | .I sv | |
67 | does not specify a valid part of the process address space. | |
68 | .TP | |
69 | .B EMFILE | |
26c32fab | 70 | The per-process limit on the number of open file descriptors has been reached. |
fea681da MK |
71 | .TP |
72 | .B ENFILE | |
e258766b | 73 | The system-wide limit on the total number of open files has been reached. |
fea681da MK |
74 | .TP |
75 | .B EOPNOTSUPP | |
76 | The specified protocol does not support creation of socket pairs. | |
77 | .TP | |
78 | .B EPROTONOSUPPORT | |
79 | The specified protocol is not supported on this machine. | |
3113c7f3 | 80 | .SH STANDARDS |
9fe752d0 | 81 | POSIX.1-2001, POSIX.1-2008, 4.4BSD. |
e511ffb6 | 82 | .BR socketpair () |
8e9b2765 | 83 | first appeared in 4.2BSD. |
1c44bd5b | 84 | It is generally portable to/from |
fea681da | 85 | non-BSD systems supporting clones of the BSD socket layer (including |
efbfd7ec | 86 | System\ V variants). |
fea681da | 87 | .SH NOTES |
fcac1f5a | 88 | On Linux, the only supported domains for this call are |
0daa9e92 | 89 | .B AF_UNIX |
fea681da | 90 | (or synonymously, |
fcac1f5a ES |
91 | .BR AF_LOCAL ) |
92 | and | |
93 | .B AF_TIPC | |
94 | .\" commit: 70b03759e9ecfae400605fa34f3d7154cccbbba3 | |
95 | (since Linux 4.12). | |
efeece04 | 96 | .PP |
0cc9687d MK |
97 | Since Linux 2.6.27, |
98 | .BR socketpair () | |
99 | supports the | |
1ae6b2c7 | 100 | .B SOCK_NONBLOCK |
0cc9687d | 101 | and |
1ae6b2c7 | 102 | .B SOCK_CLOEXEC |
57f8da4c MK |
103 | flags in the |
104 | .I type | |
105 | argument, as described in | |
0cc9687d | 106 | .BR socket (2). |
47297adb | 107 | .SH SEE ALSO |
fea681da MK |
108 | .BR pipe (2), |
109 | .BR read (2), | |
110 | .BR socket (2), | |
111 | .BR write (2), | |
5dfedcae | 112 | .BR socket (7), |
fea681da | 113 | .BR unix (7) |