z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Client connection requests in a concurrent server program

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

As shown in Figure 1, the listener socket is selected with a pending read. Then, a new connection request arrives, and the following socket() call must accept.

Figure 1 illustrates this type of connection request.

Figure 1. Accepting a client connection
*---------------------------------------------------------------------*  
* ACCEPT the connection from a client                                  * 
*---------------------------------------------------------------------* 
    EZASMI   TYPE=ACCEPT,   *Accept new connection                  C 
             S=TPIMSNO,     *On listener socket descriptor          C 
             NAME=SOCSTRUC, *Returned client socket structure       C 
             ERRNO=ERRNO,                                           C 
             RETCODE=RETCODE,C                                         C 
             ERROR=EZAERROR 
    ICM      R15,15,RETCODE  *OK ? 
    BM       EZAERROR        *- No, error indicated
    STH      R15,NEWSOC      *Returned new socket descriptor
*
SOCSTRUC DS  0F              *ACCEPT Socket address structure
SSTRFAM  DC  AL2(2)          *TCP/IP Addressing family
SSTRPORT DC  AL2(0)          *Port number
SSTRADDR DC  AL4(0)          *IP Address
SSTRRESV DC  8X'00'          *Reserved
*
TPIMSNO  DC  AL2(0)          *Listen socket descriptor
*
NEWSOC   DC  AL2(0)          *Returned socket descriptor
*
ERRNO    DC  A(0)            *Error number from EZASMI
RETCODE  DC  A(0)            *Returncode from EZASMI

The accept call returns a new socket descriptor representing the connection with the client. The original listen socket descriptor is available to a new select() call.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014