]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/socketpair.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / socketpair.2
CommitLineData
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
16socketpair \- create a pair of connected sockets
f8b3ad7f
AC
17.SH LIBRARY
18Standard 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
28The
31e9a9ec 29.BR socketpair ()
2269e870
MK
30call creates an unnamed pair of connected sockets in the specified
31.IR domain ,
fea681da
MK
32of the specified
33.IR type ,
34and using the optionally specified
35.IR protocol .
2269e870
MK
36For further details of these arguments, see
37.BR socket (2).
efeece04 38.PP
d9cb0d7d 39The file descriptors used in referencing the new sockets are returned in
e7ff7535 40.I sv[0]
fea681da 41and
e7ff7535 42.IR sv[1] .
fea681da 43The two sockets are indistinguishable.
47297adb 44.SH RETURN VALUE
c13182ef 45On success, zero is returned.
1548a03a 46On error, \-1 is returned,
fea681da 47.I errno
c112329f 48is set to indicate the error, and
1548a03a
MK
49.I sv
50is left unchanged
efeece04 51.PP
53ee58a3
MK
52On Linux (and other systems),
53.BR socketpair ()
54does not modify
55.I sv
56on failure.
5dbd04b5 57A 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
62The specified address family is not supported on this machine.
63.TP
64.B EFAULT
65The address
66.I sv
67does not specify a valid part of the process address space.
68.TP
69.B EMFILE
26c32fab 70The per-process limit on the number of open file descriptors has been reached.
fea681da
MK
71.TP
72.B ENFILE
e258766b 73The system-wide limit on the total number of open files has been reached.
fea681da
MK
74.TP
75.B EOPNOTSUPP
76The specified protocol does not support creation of socket pairs.
77.TP
78.B EPROTONOSUPPORT
79The specified protocol is not supported on this machine.
3113c7f3 80.SH STANDARDS
9fe752d0 81POSIX.1-2001, POSIX.1-2008, 4.4BSD.
e511ffb6 82.BR socketpair ()
8e9b2765 83first appeared in 4.2BSD.
1c44bd5b 84It is generally portable to/from
fea681da 85non-BSD systems supporting clones of the BSD socket layer (including
efbfd7ec 86System\ V variants).
fea681da 87.SH NOTES
fcac1f5a 88On Linux, the only supported domains for this call are
0daa9e92 89.B AF_UNIX
fea681da 90(or synonymously,
fcac1f5a
ES
91.BR AF_LOCAL )
92and
93.B AF_TIPC
94.\" commit: 70b03759e9ecfae400605fa34f3d7154cccbbba3
95(since Linux 4.12).
efeece04 96.PP
0cc9687d
MK
97Since Linux 2.6.27,
98.BR socketpair ()
99supports the
1ae6b2c7 100.B SOCK_NONBLOCK
0cc9687d 101and
1ae6b2c7 102.B SOCK_CLOEXEC
57f8da4c
MK
103flags in the
104.I type
105argument, 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)