[Previous] [Contents] [Index] [Next]

socketpair()

Create a pair of connected sockets

Synopsis:

#include <sys/types.h>
#include <sys/socket.h>

int socketpair( int d, 
                int type, 
                int protocol, 
                int * sv );

Library:

socket3r.lib, socket3s.lib

Description:

The socketpair() call creates an unnamed pair of connected sockets in the specified domain d, of the specified type, using the optionally specified protocol. The descriptors used in referencing the new sockets are returned in sv[0] and sv[1]. The two sockets are indistinguishable.

For more detailed information about socketpairs, see the section, Socketpairs in the chapter, A Socket-based IPC Tutorial.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EAFNOSUPPORT
The specified address family isn't supported on this machine.
EFAULT
The address sv doesn't specify a valid part of the process address space.
EMFILE
Too many descriptors are in use by this process.
EOPNOTSUPP
The specified protocol doesn't support creation of socket pairs.
EPROTONOSUPPORT
The specified protocol isn't supported on this machine.

Classification:

Standard Unix

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

pipe(), read(), write() in the C Library Reference


[Previous] [Contents] [Index] [Next]