xref: /original-bsd/lib/libc/sys/socketpair.2 (revision c3e32dec)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)socketpair.2	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt SOCKETPAIR 2
10.Os BSD 4.2
11.Sh NAME
12.Nm socketpair
13.Nd create a pair of connected sockets
14.Sh SYNOPSIS
15.Fd #include <sys/types.h>
16.Fd #include <sys/socket.h>
17.Ft int
18.Fn socketpair "int d" "int type" "int protocol" "int *sv"
19.Sh DESCRIPTION
20The
21.Fn socketpair
22call creates an unnamed pair of connected sockets in
23the specified domain
24.Fa d ,
25of the specified
26.Fa type ,
27and using the optionally specified
28.Fa protocol .
29The descriptors used in referencing the new sockets
30are returned in
31.Fa sv Ns [0]
32and
33.Fa sv Ns [1] .
34The two sockets are indistinguishable.
35.Sh DIAGNOSTICS
36A 0 is returned if the call succeeds, -1 if it fails.
37.Sh ERRORS
38The call succeeds unless:
39.Bl -tag -width EPROTONOSUPPORTA
40.It Bq Er EMFILE
41Too many descriptors are in use by this process.
42.It Bq Er EAFNOSUPPORT
43The specified address family is not supported on this machine.
44.It Bq Er EPROTONOSUPPORT
45The specified protocol is not supported on this machine.
46.It Bq Er EOPNOSUPPORT
47The specified protocol does not support creation of socket pairs.
48.It Bq Er EFAULT
49The address
50.Fa sv
51does not specify a valid part of the
52process address space.
53.Sh SEE ALSO
54.Xr read 2 ,
55.Xr write 2 ,
56.Xr pipe 2
57.Sh BUGS
58This call is currently implemented only for the
59.Tn UNIX
60domain.
61.Sh HISTORY
62The
63.Nm
64function call appeared in
65.Bx 4.2 .
66