The recv callable service receives data on a socket and stores it in a buffer. If no messages are available at the socket, the service either waits for a message to arrive, or fails with EWOULDBLOCK — depending on whether the socket has been defined as blocking or nonblocking, and whether the SO_RCVTIMEO socket option is in effect.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task or SRB |
Cross memory mode: | PASN = HASN |
AMODE: (BPX1RCV) | 31-bit |
AMODE: (BPX4RCV) | 64-bit |
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 BPX4RCV with the same parameters.
The name of a fullword that contains the socket file descriptor for which the receive is to be done.
The name of a field that contains the length of Buffer.
The name of a field into which the data is received.
The name of a field that contains the ALET for Buffer. You should specify a Buffer_alet of 0 for the normal case of a buffer in the user's address space (current primary address space). If a value other than 0 is specified for the Buffer_alet, the value must represent a valid entry in the dispatchable unit access list (DUAL).
The name of a field that contains information about how the data is to be received. See BPXYMSGF — Map the message flags for more information about the format of this field.
Return_code | Explanation |
---|---|
EBADF | An incorrect file descriptor was specified. The following reason codes can accompany the return code: JRFileDesNotInUse, JRFileNotOpen. |
EINTR | A signal interrupted the recv() function before any data was available. The following reason code can accompany the return code: JRSockRdwrSignal. |
EINVAL | The socket is marked shutdown for read. The following reason code can accompany the return code: JRSocketClosed. |
EIO | There has been a network or transport failure. The following reason code can accompany the return code: JRPrevSockError. |
ENOBUFS | A buffer could not be obtained. The following reason code can accompany the return code: JROutofSocketCells. |
ENOTSOCK | Socket_descriptor does not refer to a valid socket descriptor. The following reason code can accompany the return code: JRMustBeSocket. |
EWOULDBLOCK |
The following reason codes can accompany the return code: JRTimeout, JRWouldBlock. |
The name of a fullword in which the recv service stores the reason code. The recv 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 recv service.
For an example using this callable service, see BPX1RCV (recv) example.