1 .\"
   2 .\" The contents of this file are subject to the terms of the
   3 .\" Common Development and Distribution License (the "License").
   4 .\" You may not use this file except in compliance with the License.
   5 .\"
   6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   7 .\" or http://www.opensolaris.org/os/licensing.
   8 .\" See the License for the specific language governing permissions
   9 .\" and limitations under the License.
  10 .\"
  11 .\" When distributing Covered Code, include this CDDL HEADER in each
  12 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  13 .\" If applicable, add the following below this CDDL HEADER, with the
  14 .\" fields enclosed by brackets "[]" replaced with your own identifying
  15 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  16 .\"
  17 .\"
  18 .\" Copyright 1989 AT&T
  19 .\" Copyright (C) 2002, Sun Microsystems, Inc. All Rights Reserved
  20 .\" Copyright 2018 Nexenta Systems, Inc.
  21 .\"
  22 .Dd August 2, 2018
  23 .Dt SOCKETPAIR 3C
  24 .Os
  25 .Sh NAME
  26 .Nm socketpair
  27 .Nd create a pair of connected sockets
  28 .Sh LIBRARY
  29 .Lb libc
  30 .Sh SYNOPSIS
  31 .In sys/types.h
  32 .In sys/socket.h
  33 .Ft int
  34 .Fo socketpair
  35 .Fa "int domain"
  36 .Fa "int type"
  37 .Fa "int protocol"
  38 .Fa "int sv[2]"
  39 .Fc
  40 .Sh DESCRIPTION
  41 The
  42 .Fn socketpair
  43 library call creates an unnamed pair of connected sockets in the specified
  44 address family
  45 .Fa domain ,
  46 of the specified
  47 .Fa type ,
  48 that uses the optionally specified
  49 .Fa protocol .
  50 The descriptors that are used in referencing the new sockets are returned in
  51 .Fa sv Ns Bq 0
  52 and
  53 .Fa sv Ns Bq 1 .
  54 The two sockets are indistinguishable.
  55 .Sh RETURN VALUES
  56 .Fn socketpair
  57 returns -1 on failure and 0 on success.
  58 .Sh ERRORS
  59 The call succeeds unless:
  60 .Bl -tag -width Er
  61 .It Bq Er EAFNOSUPPORT
  62 The specified address family is not supported on this machine.
  63 .It Bq Er EMFILE
  64 Too many descriptors are in use by this process.
  65 .It Bq Er ENOMEM
  66 There was insufficient user memory for the operation to complete.
  67 .It Bq Er ENOSR
  68 There were insufficient STREAMS resources for the operation to complete.
  69 .It Bq Er EOPNOTSUPP
  70 The specified protocol does not support creation of socket pairs.
  71 .It Bq Er EPROTONOSUPPORT
  72 The specified protocol is not supported on this machine.
  73 .It Bq Er EACCES
  74 The process does not have appropriate privileges.
  75 .El
  76 .Sh MT-LEVEL
  77 .Sy Safe
  78 .Sh SEE ALSO
  79 .Xr pipe 2 ,
  80 .Xr read 2 ,
  81 .Xr write 2 ,
  82 .Xr socket.h 3HEAD ,
  83 .Xr attributes 5
  84 .Sh NOTES
  85 This call is currently implemented only for the
  86 .Dv AF_UNIX
  87 address family.