The accept_and_recv callable service accepts the next connection on a socket and receives the first block of data. The new socket's descriptor, the peer's remote address, and the caller's local address are also returned. The service does not return until some data has arrived.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task or SRB |
Cross memory mode: | PASN = HASN |
AMODE (BPX1ANR): | 31-bit |
AMODE (BPX4ANR): | 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 BPX4ANR with the same parameters. All parameter addresses and addresses in parameter structures are doublewords.
The name of a fullword that contains the socket descriptor for which the accept_and_recv() is to be done. This is the server's "listen socket."
The name of a fullword (doubleword) that contains the length of Remote_addr. This field is updated with the length of the socket address that is returned in Remote_addr. If you do not want the Remote_addr, specify 0 for Remote_addr_len.
The name of an area that contains the sockaddr structure that is returned for the client that is connecting.
The name of a fullword (doubleword) that contains the length of Local_addr. This field is updated with the length of the socket address that is returned in Local_addr. If you do not want the Local_addr, specify 0 for Local_addr_len.
The name of an area that contains the sockaddr structure that is returned for the server's port on which the connection arrives.
The name of a fullword that contains the length of Buffer. If this value is zero, no receive is done, and the accept_and_recv request completes when a connection is available.
The name of an area that contains the received data.
The name of a field that contains the alet of the buffer. For buffers in the caller's primary address space, this value should be 0.
The name of a fullword in which the accept_and_recv service stores the return code. The accept_and_recv service returns Return_code only if Return_value is -1. For a complete list of possible return code values, see z/OS UNIX System Services Messages and Codes. The accept_and_recv service can return one of the following values in the Return_code parameter:
Return_code | Explanation |
---|---|
EBADF | A file descriptor that was not valid was supplied. The following reason codes can accompany the return code: JRFileDesNotInUse, JRFileNotOpen. |
ECONNRESET | The connection was reset by a peer. The following reason code can accompany the return code: JRSockNotCon. |
ECONNABORTED | The connection has been dropped. |
EFAULT | An address that was passed cannot be accessed in the key of the caller. |
EINTR | A signal interrupted the accept_and_recv service before a connection had arrived. The following reason code can accompany the return code: JRSignalReceived. |
EINTRNODATA | A signal interrupted the accept_and_recv service after a connection had been established but before any data had arrived. This is a partial success, and the session has been established. A new socket descriptor is returned in Accepted_socket. |
EIO | An I/O error occurred on one of the descriptors. |
EINVAL | The socket is not accepting connections. |
EISCONN | Accepted_socket is either bound or already connected. |
EMFILE | OPEN_MAX descriptors are currently open in the calling process. |
ENOBUFS | The service could not obtain a buffer. The following reason code can accompany the return code: JROutofSocketCells. |
ENOMEM | The service could not obtain memory to complete the operation. |
ENOREUSE | Socket descriptor reuse is not supported. |
ENOSR | Insufficient STREAMS resources were available for the operation to complete. |
ENOTSOCK | Socket_desc does not refer to a valid socket descriptor.The following reason code can accompany the return code: JRMustBeSocket. |
EOPNOTSUPP | The socket type of the specified socket does not accept connections; or O_NONBLOCK is set for this socket. Nonblocking mode is not supported for this function. |
EWOULDBLOCK | A new connection has been established, but the SO_RCVTIMEO timeout value was reached before data was available. This is a partial success, and the session has been established. A new socket descriptor is returned in Accepted_socket. |
The name of a fullword in which the accept_and_recv service stores the reason code. The accept_and_recv service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. See z/OS UNIX System Services Messages and Codes for the reason codes.
None.
For an example using this callable service, see BPX1ANR (accept_and_recv) example.