The accept callable service allows a server to accept a connection request from a client. It extracts the first connection on the queue of pending connections, creates a new socket with the same properties as the specified socket, and allocates a new descriptor for that socket. If there are no connections pending, the service either blocks until a connection request is received, or fails with an EWOULDBLOCK, depending on whether the specified socket is marked as blocking or nonblocking.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task or SRB |
Cross memory mode: | PASN = HASN |
AMODE (BPX1ACP): | 31-bit task or SRB mode |
AMODE (BPX4ACP): | 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 BPX4ACP with the same parameters.
The name of a fullword that contains the socket file descriptor for which the accept is to be done.
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 field can be zero if no value is passed for Sockaddr. The size of the field should be less than 4096 bytes (4KB) in length.
The name of a field that contains the socket address of the connecting client. The format of Sockaddr is determined by the domain in which the client resides. This field can be null if the caller is not interested in the client address. For more information about the format of this structure, see BPXYSOCK — Map SOCKADDR structure and constants.
Return_code | Explanation |
---|---|
EBADF | An incorrect file descriptor was specified. The following reason codes can accompany the return code: JRFileDesNotInUse, or JRFileNotOpen. |
ECONNABORTED | Software-caused connection termination. |
EINTR | A signal interrupted the accept service before any connections were available. The following reason code can accompany the return code: JRSignalReceived. |
EINVAL | The socket is not accepting connections. A listen must be done prior to the accept. The following reason code can accompany the return code: JRListenNotDone. |
EIO | There has been a network or transport failure. The following reason codes can accompany the return code: JRInetRecycled, JRPrevSockError. |
ENFILE | Too many files are open in the system. The following reason code can accompany the return code: JRMaxSockets. |
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. |
EOPNOTSUPP | The referenced socket is not a type that supports the requested function. |
EWOULDBLOCK | The socket file descriptor is marked nonblocking, and no connections are present to be accepted. |
The name of a fullword where the accept service stores the reason code. The accept 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.
Before calling the accept service, you can find out if the socket is pending a connection by doing a read select with the select callable service.
There are no restrictions on the use of the accept service.
For an example using this callable service, see BPX1ACP (accept) example.