LISTEN

The LISTEN call completes the bind, if BIND has not already been called for the socket, and creates a connection-request queue of a specified length for incoming connection requests.

Restriction: The LISTEN call is not supported for datagram sockets or raw sockets.

The LISTEN call is used by a server to receive connection requests from clients. When a connection request is received, a new socket is created by a subsequent ACCEPT call, and the original socket continues to listen for additional connection requests. The LISTEN call converts an active socket to a passive socket and conditions it to accept connection requests from clients. Once a socket becomes passive, it cannot initiate connection requests.

Example of LISTEN call

SOC_FUNCTION DC   CL16'LISTEN'
S            DS   H
BACKLOG      DS   F
ERRNO        DS   F
RETCODE      DS   F
 
             CALL DFHSOKET,(SOC_FUNCTION,S,BACKLOG,ERRNO,RETCODE)

Input parameters

SOC_FUNCTION
A 16-byte character field containing LISTEN. The field is left-justified and padded to the right with blanks.
S
A halfword binary number set to the socket descriptor.
BACKLOG
A fullword binary number set to the number of communication requests to be queued. Specify a value of 5 for this parameter.

Output parameters

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
A fullword binary field that returns one of the following:
Value
Description
0
Successful call
-1
Check ERRNO for an error code