Syntax
#include <sys/types.h>
#include <sys/socket.h>
int socketpair(int address_family,
int type,
int protocol,
int *socket_vector)
Threadsafe: Yes
|
The socketpair() function is
used to create a pair of
unnamed, connected sockets
in the AF_UNIX address_family.
Parameters
- address_family
- (Input) The address family to be used with the sockets.
Supported values are:
- AF_UNIX
- For interprocess communications between processes on the
same system in the UNIX domain.
- type
- (Input) The type of communications desired.
Supported values are:
- SOCK_DGRAM
- Indicates a datagram socket is desired.
- SOCK_STREAM
- Indicates a full-duplex stream socket is desired.
- protocol
- (Input) The protocol to be used on the sockets.
Supported values are:
- 0
- Indicates the default protocol for the type selected is to be used.
- socket_vector
- (Output) An integer array of size two that will
contain the socket descriptors.
Return Value
socketpair() returns an integer. Possible values are:
- -1 (unsuccessful)
- 0 (successful)
Error Conditions
When socketpair() fails, errno can be set to one of the following:
- [EAFNOSUPPORT]
- The type of socket is not supported in this protocol family.
- [EFAULT]
- Bad address.
- [EINVAL]
- Parameter not valid.
- [EIO]
- Input/output error.
- [EMFILE]
- Too many descriptions for this process.
- [ENFILE]
- Too many descriptions in system.
- [ENOBUFS]
- There is not enough buffer space for the requested operation.
- [EOPNOTSUPP]
- Operation not supported.
- [EPROTONOSUPPORT]
- No protocol of the specified type and domain exists.
- [ESOCKTNOSUPPORT]
- The specified socket type is not supported.
- [EUNKNOWN]
- Unknown system state.
Error Messages
- CPE3418 E
- Possible APAR condition or hardware failure.
- CPF9872 E
- Program or service program &1
in library &2 ended. Reason code &3.
- CPFA081 E
- Unable to set return value or error code.
Usage Notes
- The socket address families and types supported by sockets are
defined in <sys/socket.h>.
Related Information
socket()--Create Socket