The getsockname or getpeername callable service obtains the name of a socket or the name of a peer connected to a socket.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task or SRB |
Cross memory mode: | PASN = HASN |
AMODE (BPX1GNM): | 31-bit task or SRB mode |
AMODE (BPX4GNM): | 64-bit task mode only |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
AMODE 64 callers use BPX4GNM with the same parameters.
|
The name of a fullword that contains the socket file descriptor for which the service is to be performed.
The name of a field that contains the operation option. The value of this field determines whether the service to be performed is getsockname or getpeername. See BPXYSOCK — Map SOCKADDR structure and constants for valid Operation values.
The name of a field that contains the length of Sockaddr. On return, this field specifies the size required to represent the address of the connecting socket. If this value is larger than the size supplied on input, the information contained in Sockaddr is truncated to the length supplied on input. The size of this field must be less than 4096 bytes (4KB) in length. The size of the buffer that is specified must be the maximum length that the sockaddr could be on output.
The name of a field in which the socket name or peer name is to be returned. See BPXYSOCK — Map SOCKADDR structure and constants for valid Operation values.
Return_code | Explanation |
---|---|
EBADF | The socket descriptor is incorrect. The following reason codes can accompany the return code: JRFileDesNotInUse, JRFileNotOpen. |
EINVAL | The length that is specified by the sockaddr_length operand is too small to allow the name to be returned. The following reason code can accompany the return code: JRSocketCallParmError. |
ENOBUFS | Unable to obtain a buffer. Consult Reason_code to determine the exact reason the error occurred. The following reason code can accompany the return code: JROutofSocketCells. |
ENOTCONN | getpeername() was specified and the socket is not connected. |
ENOTSOCK | Socket_descriptor does not refer to a valid socket descriptor. The following reason code can accompany the return code: JRMustBeSocket. |
The name of a fullword in which the getsockname or getpeername service stores the reason code. The getsockname or getpeername service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
There are no restrictions on the use of the getsockname or getpeername service.
For an example using this callable service, see BPX1GNM (getpeername or getsockname) example.