*---------------------------------------------------------------------*
* Take socket from main process *
*---------------------------------------------------------------------*
EZASMI TYPE=TAKESOCKET, *Takesocket C
CLIENT=TPIMCLNI, *Main task client id structure C
SOCRECV=TPISSOD, *Main task socket descriptor C
ERRNO=ERRNO, C
RET CODE=RETCODE, C
ERROR=EZAERROR
ICM R15,15,RETCODE *Did we do well ?
BM EZAERROR *- No, deal with it.
STH R15,TPISNSOD *Server subtask socket descr.no
*
TPIMCLNI DS 0C *Main task client id
TPIMCDOM DC A(0) *Domain: AF-INET
TPIMCNAM DC CL8' ' *Our address space name
TPIMCTSK DC CL8' ' *Main task TCB address in EBCDIC
DC 20X'00' *Reserved (part of clientid)
*
TPISSOD DC AL2(0) *Parent socket descr. no.
TPISNSOD DC AL2(0) *Subtask socket descr. no.
On the takesocket() call, you specify the full client ID of the process that gave the socket, and you specify the socket descriptor number used by the process that gave the socket.
A new socket descriptor number to be used by the subtask is returned in the RETCODE when the takesocket() call is successful. As soon as your subtask has taken the socket, the main process is posted in its pending select with a pending exception activity; this means that the main process must close its socket descriptor.
In Figure 1, the client sends its request to the subtask, which processes it and sends back a reply.
Finally, the client process and the server subtask close their sockets, and the server subtask reenters wait-for-work status.