'\"macro stdmacro
.if n .pH g3n.socketpair @(#)socketpair	40.7 of 1/29/90
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} socketpair 3N "" "\&"
.if \nX=1 .ds x} socketpair 3N ""
.if \nX=2 .ds x} socketpair 3N "" "\&"
.if \nX=3 .ds x} socketpair "" "" "\&"
.TH \*(x}
.SH NAME
\f4socketpair\fP \- create a pair of connected sockets
.SH SYNOPSIS
.nf
.ft CW
#include <sys/types.h>
#include <sys/socket.h>
.LP
.ft CW
socketpair(d, type, protocol, sv)
int d, type, protocol;
int sv[2];
.fi
.SH DESCRIPTION
.LP
The \f4socketpair(\|)\f1 library call creates an unnamed pair of
connected sockets in the specified address family
.IR d ,
of the specified
.I type ,
and using the optionally specified
.IR protocol .
The descriptors used in referencing the new sockets
are returned in
.IR sv [0]
and
.IR sv [1].
The two sockets are indistinguishable.
.SH RETURN VALUE
.LP
\f4socketpair(\|)\f1 returns a \-1 on failure, otherwise it returns the
number of the second file descriptor it creates.
.SH ERRORS
.LP
The call succeeds unless:
.TP 20
\f4EMFILE\f1
Too many descriptors are in use by this process.
.TP
\f4EAFNOSUPPORT\f1
The specified address family is not supported on this machine.
.TP
\f4EPROTONOSUPPORT\f1
The specified protocol is not supported on this machine.
.TP
\f4EOPNOSUPPORT\f1
The specified protocol does not support creation of socket pairs.
.\".TP
.\".SM EFAULT
.\"The address
.\".I sv
.\"does not specify a valid part of the
.\"process address space.
.TP
\f4ENOMEM\f1
There was insufficient user memory for the operation to complete.
.TP
\f4ENOSR\f1
There were insufficient
.SM STREAMS
resources for the operation to
complete.
.SH "SEE ALSO"
\f4pipe\fP(2), 
\f4read\fP(2),
\f4write\fP(2)
.SH NOTES
.LP
This call is currently implemented only for the \f4AF_UNIX\f1
address family.
