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


Giving a socket to a subtask

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

The socket represented by the new socket descriptor has to be passed to an available subtask. Which technique the main process uses to find an available subtask is not important. Assume that the main process has located an available subtask to which it gives the socket by way of a givesocket() call as shown in Figure 1:
Figure 1. Giving a socket to a subtask
*---------------------------------------------------------------------*  
*Give socket to subtask                                               * 
*---------------------------------------------------------------------* 
      MVC   CLNNAME,TPIMCNAM    *Our Client ID Address Space Name
      MVC   CLNTASK,TPISTCBE    *Give to this subtask
      EZASMI TYPE=GIVESOCKET,   *Givesocket                         C
            S=NEWSOC,           *Give this socket descriptor        C
            CLIENT=CLNSTRUC,    *- to a specific child process      C
            ERRNO=ERRNO,                                            C
            RETCODE=RETCODE,                                        C 
            ERROR=EZAERROR
            ICM   R15,15,RETCODE *OK ?
            BM    EZAERROR       *- No, tell about it. 
*
*      CLNSTRUC DS    0F         *GIVESOCKET: Client structure
CLNFAM   DC    A(2)              *TCP/IP Addressing family
CLNNAME  DC    CL8' '            *Address space name of target 
CLNTASK  DC    CL8' '            *Task ID of child process subtask
CLNRESV  DC    XL20'00'          *Reserved 
*
NEWSOC   DC    AL2(0)            *Socket descriptor from Accept 
* 
ERRNO    DC    A(0)              *Error number from EZASMI 
RETCODE  DC    A(0)              *Returncode from EZASMI 
If you are programming in C, you might not be able to determine the full client ID of the subtask. In that case, you can pass the task ID field as eight blanks on the givesocket() call, which means that any task within your own address space can take the socket, but only the task to which you pass the socket descriptor number will actually take it.

After you have issued the givesocket() call, you must include the given socket descriptor in the exception select mask on the next select() call.

Your main process is now ready to wake up the selected subtask by way of a post system call.

If no other sockets were selected on the previous select() call, your main process can build a new set of select masks, and issue a new select() call.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014