#include <sys/types.h> #include <sys/socket.h> int socketpair(int address_family, int type, int protocol, int *socket_vector)
#define _XOPEN_SOURCE 520 #include <sys/socket.h> int socketpair(int address_family, int type, int protocol, int socket_vector[2])
The socketpair() function is used to create a pair of unnamed, connected sockets in the AF_UNIX or AF_UNIX_CCSID address_family.
There are two versions of the API, as shown above. The base i5/OS API uses BSD 4.3 structures and syntax. The other uses syntax and structures compatible with the UNIX 98 programming interface specifications. You can select the UNIX 98 compatible interface with the _XOPEN_SOURCE macro.
AF_UNIX or AF_UNIX_CCSID | For interprocess communications between processes on the same system in the UNIX domain. |
SOCK_DGRAM | Indicates a datagram socket is desired. |
SOCK_STREAM | Indicates a full-duplex stream socket is desired. |
0 | Indicates the default protocol for the type selected is to be used. |
No authorization is required.
socketpair() returns an integer. Possible values are:
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. |
Message ID | Error Message Text |
---|---|
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. |
API introduced: V3R1
Top | UNIX-Type APIs | APIs by category |