2 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH SOCKETPAIR 3XNET "Jun 10, 2002"
12 socketpair \- create a pair of connected sockets
16 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lxnet\fR [ \fIlibrary\fR ... ]
17 #include <sys/socket.h>
19 \fBint\fR \fBsocketpair\fR(\fBint\fR \fIdomain\fR, \fBint\fR \fItype\fR, \fBint\fR \fIprotocol\fR, \fBint\fR \fIsocket_vector\fR\fB[2]\fR);
25 The \fBsocketpair()\fR function creates an unbound pair of connected sockets in
26 a specified \fIdomain\fR, of a specified \fBtype\fR, under the protocol
27 optionally specified by the \fIprotocol\fR argument. The two sockets are
28 identical. The file descriptors used in referencing the created sockets are
29 returned in \fIsocket_vector\fR\fB0\fR and \fIsocket_vector\fR\fB1\fR.
32 The \fItype\fR argument specifies the socket type, which determines the
33 semantics of communications over the socket. The socket types supported by the
34 system are implementation-dependent. Possible socket types include:
38 \fB\fBSOCK_STREAM\fR\fR
41 Provides sequenced, reliable, bidirectional, connection-mode byte streams, and
42 may provide a transmission mechanism for out-of-band data.
48 \fB\fBSOCK_DGRAM\fR\fR
51 Provides datagrams, which are connectionless-mode, unreliable messages of fixed
58 \fB\fBSOCK_SEQPACKET\fR\fR
61 Provides sequenced, reliable, bidirectional, connection-mode transmission path
62 for records. A record can be sent using one or more output operations and
63 received using one or more input operations, but a single operation never
64 transfers part of more than one record. Record boundaries are visible to the
65 receiver via the MSG_EOR flag.
70 If the \fIprotocol\fR argument is non-zero, it must specify a protocol that is
71 supported by the address family. The protocols supported by the system are
72 implementation-dependent.
75 The process may need to have appropriate privileges to use the
76 \fBsocketpair()\fR function or to create some sockets.
84 Specifies the communications domain in which the sockets are to be created.
93 Specifies the type of sockets to be created.
102 Specifies a particular protocol to be used with the sockets. Specifying a
103 \fIprotocol\fR of 0 causes \fBsocketpair()\fR to use an unspecified default
104 protocol appropriate for the requested socket type.
110 \fB\fIsocket_vector\fR\fR
113 Specifies a 2-integer array to hold the file descriptors of the created socket
120 The documentation for specific address families specifies which protocols each
121 address family supports. The documentation for specific protocols specifies
122 which socket types each protocol supports.
125 The \fBsocketpair()\fR function is used primarily with UNIX domain sockets and
126 need not be supported for other domains.
130 Upon successful completion, this function returns 0. Otherwise, \(mi1 is
131 returned and \fBerrno\fR is set to indicate the error.
135 The \fBsocketpair()\fR function will fail if:
139 \fB\fBEAFNOSUPPORT\fR\fR
142 The implementation does not support the specified address family.
151 No more file descriptors are available for this process.
160 No more file descriptors are available for the system.
166 \fB\fBEOPNOTSUPP\fR\fR
169 The specified protocol does not permit creation of socket pairs.
175 \fB\fBEPROTONOSUPPORT\fR\fR
178 The protocol is not supported by the address family, or the protocol is not
179 supported by the implementation.
185 \fB\fBEPROTOTYPE\fR\fR
188 The socket type is not supported by the protocol.
193 The \fBsocketpair()\fR function may fail if:
200 The process does not have appropriate privileges.
209 Insufficient resources were available in the system to perform the operation.
218 Insufficient memory was available to fulfill the request.
227 There were insufficient STREAMS resources available for the operation to
234 See \fBattributes\fR(5) for descriptions of the following attributes:
242 ATTRIBUTE TYPE ATTRIBUTE VALUE
244 Interface Stability Standard
252 \fBsocket\fR(3XNET), \fBattributes\fR(5), \fBstandards\fR(5)