.\" Copyright (c) 1983, 1991 The Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)socketpair.2 6.4 (Berkeley) 03/10/91 .\" .Dd .Dt SOCKETPAIR 2 .Os BSD 4.2 .Sh NAME .Nm socketpair .Nd create a pair of connected sockets .Sh SYNOPSIS .Fd #include .Fd #include .Ft int .Fn socketpair "int d" "int type" "int protocol" "int *sv" .Sh DESCRIPTION The .Fn socketpair call creates an unnamed pair of connected sockets in the specified domain .Fa d , of the specified .Fa type , and using the optionally specified .Fa protocol . The descriptors used in referencing the new sockets are returned in .Fa sv Ns [0] and .Fa sv Ns [1] . The two sockets are indistinguishable. .Sh DIAGNOSTICS A 0 is returned if the call succeeds, -1 if it fails. .Sh ERRORS The call succeeds unless: .Bl -tag -width EPROTONOSUPPORTA .It Bq Er EMFILE Too many descriptors are in use by this process. .It Bq Er EAFNOSUPPORT The specified address family is not supported on this machine. .It Bq Er EPROTONOSUPPORT The specified protocol is not supported on this machine. .It Bq Er EOPNOSUPPORT The specified protocol does not support creation of socket pairs. .It Bq Er EFAULT The address .Fa sv does not specify a valid part of the process address space. .Sh SEE ALSO .Xr read 2 , .Xr write 2 , .Xr pipe 2 .Sh BUGS This call is currently implemented only for the .Tn UNIX domain. .Sh HISTORY The .Nm function call appeared in .Bx 4.2 .