ACCEPT
A server issues the ACCEPT call to accept a connection request from a client. The call points to a socket that was previously created with a SOCKET call and marked by a LISTEN call.
The ACCEPT call is a blocking call. When issued, the ACCEPT
call performs these functions:
- Accepts the first connection on a queue of pending connections.
- Creates a new socket with the same properties as an existing socket, and returns its descriptor in RETCODE. The original sockets remain available to the calling program to accept more connection requests.
- The address of the client is returned in NAME for use by subsequent server calls.
Note:
- If the queue has no pending connection requests, ACCEPT blocks the socket.
- The interface does not screen clients. As a result, the program must control which connection requests it accepts, but it can close a connection immediately after discovering the identity of the client.
Example of ACCEPT call
SOC_FUNCTION DC CL16'ACCEPT'
S DS H
NAME DS 0XL16
FAMILY DS H
PORT DS H
IP_ADDRESS DS F
RESERVED DS CL8
ERRNO DS F
RETCODE DS F
CALL DFHSOKET,(SOC_FUNCTION,S,NAME,ERRNO,RETCODE)
Input parameters
- SOC_FUNCTION
- A 16-byte character field containing ACCEPT. Left-justify the field and pad it on the right with blanks.
- S
- A halfword binary number specifying the descriptor of a socket that was previously created with a SOCKET call. In a concurrent server, the server listens on this socket.
Output parameters
- NAME
- A socket address structure that contains the client socket address.
- FAMILY
- A halfword binary field specifying the addressing family. The call returns 2 for the AF_INET socket. For more information on AF_INET and AF_INET6, see the z/OS® 1.9 Communications Server IPv6 Network and Application Design Guide.
- PORT
- A halfword binary field that is set to the client port number.
- IP_ADDRESS
- A fullword binary field that is set to the 32-bit IPv4 address, in network byte order, of the client host machine. IPv6 addressing is not supported.
- RESERVED
- Specifies 8 bytes of binary zeros. This field is required, but not used.
- ERRNO
- A fullword binary field. If RETCODE is negative, the field contains an error number. See Return codes for information about ERRNO return codes.
- RETCODE
- If the RETCODE value is positive, the RETCODE value is the new
socket number.
If the RETCODE value is negative, check the ERRNO field for an error number.