z/OS Cryptographic Services System SSL Programming
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Non-Blocking socket primer

z/OS Cryptographic Services System SSL Programming
SC14-7495-00

When a server wants to communicate with clients by using a socket, these routines are used:

Table 1. Server communicating with clients by way of a socket
Routine Purpose
1) socket() Create a socket
2) bind() Register the socket
3) listen() Indicate willingness to accept connections
4) accept() Accept a connection request
5) Read request  
6) Write response  
7) Return to step 4  

Once the accept() routine is called, the server blocks until data is available for the socket. Problems arise when the server wants to monitor multiple sockets simultaneously or if the server wants to perform other tasks until data is available on the socket. However, by configuring the socket as non-blocking, these problems may be avoided. For more information, see Enable/disable non-blocking mode. When using non-blocking sockets, the select() routine is used to instruct the system to notify the server application when data is available on a particular socket.

Table 2. Using the select() routine
Routine Purpose
1) socket() Create a socket
2) bind() Register the socket
3) listen() Indicate willingness to accept connections
4) Set socket as non-blocking See Enable/disable non-blocking mode
5) select() Monitor a number of sockets
6) accept() Accept a connection request
7) Read request If unable to read all data, return to step 5
8) Write response If unable to write all data, return to step 5
9) Return to step 4  

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014