1 '\" te
   2 .\" Copyright 1989 AT&T
   3 .\" Copyright (C) 2002, Sun Microsystems, Inc. All Rights Reserved
   4 .\" 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.
   5 .\" 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.
   6 .\" 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]
   7 .TH SOCKETPAIR 3SOCKET "Jan 10, 2001"
   8 .SH NAME
   9 socketpair \- create a pair of connected sockets
  10 .SH SYNOPSIS
  11 .LP
  12 .nf
  13 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR ... ]
  14 #include <sys/types.h>
  15 #include <sys/socket.h>
  16 
  17 \fBint\fR \fBsocketpair\fR(\fBint\fR \fIdomain\fR, \fBint\fR \fItype\fR, \fBint\fR \fIprotocol\fR, \fBint\fR \fIsv\fR[2]);
  18 .fi
  19 
  20 .SH DESCRIPTION
  21 .sp
  22 .LP
  23 The \fBsocketpair()\fR library call creates an unnamed pair of connected
  24 sockets in the specified address family \fIdomain\fR, of the specified
  25 \fItype\fR, that uses the optionally specified \fIprotocol\fR. The descriptors
  26 that are used in referencing the new sockets are returned in \fIsv\fR[0] and
  27 \fIsv\fR[1]. The two sockets are indistinguishable.
  28 .SH RETURN VALUES
  29 .sp
  30 .LP
  31 \fBsocketpair()\fR returns \fB\(mi1\fR on failure and \fB0\fR on success.
  32 .SH ERRORS
  33 .sp
  34 .LP
  35 The call succeeds unless:
  36 .sp
  37 .ne 2
  38 .na
  39 \fB\fBEAFNOSUPPORT\fR\fR
  40 .ad
  41 .RS 19n
  42 The specified address family is not supported on this machine.
  43 .RE
  44 
  45 .sp
  46 .ne 2
  47 .na
  48 \fB\fBEMFILE\fR\fR
  49 .ad
  50 .RS 19n
  51 Too many descriptors are in use by this process.
  52 .RE
  53 
  54 .sp
  55 .ne 2
  56 .na
  57 \fB\fBENOMEM\fR\fR
  58 .ad
  59 .RS 19n
  60 There was insufficient user memory for the operation to complete.
  61 .RE
  62 
  63 .sp
  64 .ne 2
  65 .na
  66 \fB\fBENOSR\fR\fR
  67 .ad
  68 .RS 19n
  69 There were insufficient \fBSTREAMS\fR resources for the operation to complete.
  70 .RE
  71 
  72 .sp
  73 .ne 2
  74 .na
  75 \fB\fBEOPNOTSUPP\fR\fR
  76 .ad
  77 .RS 19n
  78 The specified protocol does not support creation of socket pairs.
  79 .RE
  80 
  81 .sp
  82 .ne 2
  83 .na
  84 \fB\fBEPROTONOSUPPORT\fR\fR
  85 .ad
  86 .RS 19n
  87 The specified protocol is not supported on this machine.
  88 .RE
  89 
  90 .sp
  91 .ne 2
  92 .na
  93 \fB\fBEACCES\fR\fR
  94 .ad
  95 .RS 19n
  96 The process does not have appropriate privileges.
  97 .RE
  98 
  99 .SH ATTRIBUTES
 100 .sp
 101 .LP
 102 See \fBattributes\fR(5) for descriptions of the following attributes:
 103 .sp
 104 
 105 .sp
 106 .TS
 107 box;
 108 c | c
 109 l | l .
 110 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 111 _
 112 MT-Level        Safe
 113 .TE
 114 
 115 .SH SEE ALSO
 116 .sp
 117 .LP
 118 \fBpipe\fR(2), \fBread\fR(2), \fBwrite\fR(2), \fBsocket.h\fR(3HEAD),
 119 \fBattributes\fR(5)
 120 .SH NOTES
 121 .sp
 122 .LP
 123 This call is currently implemented only for the \fBAF_UNIX\fR address family.