Waiting for Activity on Sockets
Particularly when implementing an application that serves multiple clients or manages multiple sockets simultaneously, you might not want to block the application that is waiting for activity on just one socket (such as by issuing SOCKET TYPE=ACCEPT for a server listening socket when no connection requests are available to be accepted).
To wait for activity on any sockets managed by a TCP/IP application, use a SOCKET TYPE=SELECT command. To wait for activity on the sockets, any or all of read, write, and exception lists can be passed to the SOCKET TYPE=SELECT command. You can also specify a timeout value so that the command ends after a specified time, even if no activity occurred on any socket.
SOCKET TYPE=SELECT READ=(0,1) EXCEPT=2 TIMEOUT=15
BNH610I SOCKET 1 READY FOR 'READ'
If multiple sockets had activity, a BNH610I message is issued for each socket that had activity, with the message variable containing a value for each type of event that occurred for the socket.
BNH609I SELECT REQUEST HAS TIMED OUT
This error can be prevented in a couple of ways. One way is to limit the list to the descriptors that fit in the list and to close any others. Another way is to create multiple lists and rotate calls of SOCKET TYPE=SELECT through the different lists, perhaps using a relatively small TIMEOUT value so that no socket has to wait very long for its activity to be processed.