.\" .\" 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 .\" http://www.opengroup.org/bookstore/. .\" .\" 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 SunOS 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. .\" .\" This notice shall appear on any product containing this material. .\" .\" 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. .\" .\" 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. .\" .\" 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] .\" .\" .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. .\" Portions Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved. .\" .TH SOCKETPAIR 3XNET "Jun 10, 2002" .SH NAME socketpair \- create a pair of connected sockets .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lxnet\fR [ \fIlibrary\fR ... ] #include \fBint\fR \fBsocketpair\fR(\fBint\fR \fIdomain\fR, \fBint\fR \fItype\fR, \fBint\fR \fIprotocol\fR, \fBint\fR \fIsocket_vector\fR\fB[2]\fR); .fi .SH DESCRIPTION .sp .LP The \fBsocketpair()\fR function creates an unbound pair of connected sockets in a specified \fIdomain\fR, of a specified \fBtype\fR, under the protocol optionally specified by the \fIprotocol\fR argument. The two sockets are identical. The file descriptors used in referencing the created sockets are returned in \fIsocket_vector\fR\fB0\fR and \fIsocket_vector\fR\fB1\fR. .sp .LP The \fItype\fR argument specifies the socket type, which determines the semantics of communications over the socket. The socket types supported by the system are implementation-dependent. Possible socket types include: .sp .ne 2 .na \fB\fBSOCK_STREAM\fR\fR .ad .RS 18n Provides sequenced, reliable, bidirectional, connection-mode byte streams, and may provide a transmission mechanism for out-of-band data. .RE .sp .ne 2 .na \fB\fBSOCK_DGRAM\fR\fR .ad .RS 18n Provides datagrams, which are connectionless-mode, unreliable messages of fixed maximum length. .RE .sp .ne 2 .na \fB\fBSOCK_SEQPACKET\fR\fR .ad .RS 18n Provides sequenced, reliable, bidirectional, connection-mode transmission path for records. A record can be sent using one or more output operations and received using one or more input operations, but a single operation never transfers part of more than one record. Record boundaries are visible to the receiver via the MSG_EOR flag. .RE .sp .LP If the \fIprotocol\fR argument is non-zero, it must specify a protocol that is supported by the address family. The protocols supported by the system are implementation-dependent. .sp .LP The process may need to have appropriate privileges to use the \fBsocketpair()\fR function or to create some sockets. .SH PARAMETERS .sp .ne 2 .na \fB\fIdomain\fR\fR .ad .RS 17n Specifies the communications domain in which the sockets are to be created. .RE .sp .ne 2 .na \fB\fItype\fR\fR .ad .RS 17n Specifies the type of sockets to be created. .RE .sp .ne 2 .na \fB\fIprotocol\fR\fR .ad .RS 17n Specifies a particular protocol to be used with the sockets. Specifying a \fIprotocol\fR of 0 causes \fBsocketpair()\fR to use an unspecified default protocol appropriate for the requested socket type. .RE .sp .ne 2 .na \fB\fIsocket_vector\fR\fR .ad .RS 17n Specifies a 2-integer array to hold the file descriptors of the created socket pair. .RE .SH USAGE .sp .LP The documentation for specific address families specifies which protocols each address family supports. The documentation for specific protocols specifies which socket types each protocol supports. .sp .LP The \fBsocketpair()\fR function is used primarily with UNIX domain sockets and need not be supported for other domains. .SH RETURN VALUES .sp .LP Upon successful completion, this function returns 0. Otherwise, \(mi1 is returned and \fBerrno\fR is set to indicate the error. .SH ERRORS .sp .LP The \fBsocketpair()\fR function will fail if: .sp .ne 2 .na \fB\fBEAFNOSUPPORT\fR\fR .ad .RS 19n The implementation does not support the specified address family. .RE .sp .ne 2 .na \fB\fBEMFILE\fR\fR .ad .RS 19n No more file descriptors are available for this process. .RE .sp .ne 2 .na \fB\fBENFILE\fR\fR .ad .RS 19n No more file descriptors are available for the system. .RE .sp .ne 2 .na \fB\fBEOPNOTSUPP\fR\fR .ad .RS 19n The specified protocol does not permit creation of socket pairs. .RE .sp .ne 2 .na \fB\fBEPROTONOSUPPORT\fR\fR .ad .RS 19n The protocol is not supported by the address family, or the protocol is not supported by the implementation. .RE .sp .ne 2 .na \fB\fBEPROTOTYPE\fR\fR .ad .RS 19n The socket type is not supported by the protocol. .RE .sp .LP The \fBsocketpair()\fR function may fail if: .sp .ne 2 .na \fB\fBEACCES\fR\fR .ad .RS 11n The process does not have appropriate privileges. .RE .sp .ne 2 .na \fB\fBENOBUFS\fR\fR .ad .RS 11n Insufficient resources were available in the system to perform the operation. .RE .sp .ne 2 .na \fB\fBENOMEM\fR\fR .ad .RS 11n Insufficient memory was available to fulfill the request. .RE .sp .ne 2 .na \fB\fBENOSR\fR\fR .ad .RS 11n There were insufficient STREAMS resources available for the operation to complete. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP .BR socket (3XNET), .BR attributes (7), .BR standards (7)