The SockSelect() call monitors the activity on a socket with regard to readability, readiness for writing, and pending exceptional conditions.


>>--SockSelect(reads, writes, excepts--+-------------+--)----------------><
                                       +--, timeout--+



is the number of sockets to be checked for readability.


is the number of sockets to be checked for readiness for writing.


is the number of sockets to be checked for pending exceptional conditions. For Network Services sockets, the only pending exceptional condition is out-of-band data in the receive buffer.


is the maximum number of seconds the system waits for the selection to complete. Set the timeout parameter to 0 for a blocking operation. If the socket is ready, the return will be immediate.

Each parameter specifying a number of sockets is qualified by a stem variable which is queried and set by this function. The stem variable has the following format: stem.0 contains the number of sockets, stem.1 the first socket, and so on. Upon return, the stem variables are reset to the sockets that are ready. If any of the stem variables are empty (), or no parameter is passed, no sockets for that type are checked.

The timeout value must be integral (no fractional values). Nonnumeric and negative numbers are considered to be 0. If no timeout value is passed, an empty string () is assumed.

If the timeout value is 0, SockSelect() does not wait before returning. If the timeout value is an empty string (), SockSelect() does not time out, but returns when a socket becomes ready. If the timeout value is in seconds, SockSelect() waits for the specified interval before returning. It checks all indicated sockets at the same time and returns as soon as one of them is ready.

Return values:

The number of ready sockets is returned. The value 0 indicates an expired time limit. In this case, the stem variables are not modified. The value -1 indicates an error. You can get the specific error code SockSock_Errno() or SockPSock_Errno(). Possible values are:


socket is not a valid socket descriptor.


The address is not valid.


Invalid argument.


Interrupted system call.


r.0 = 2                     /* specify 2 sockets for read in stem r. */
r.1 = 101
r.2 = 102
                            /* specify 1 socket for write in stem w. */
w.0 = 1
w.1 = 103
                          /* no sockets for exceptions in stem e.    */
e.0 = 0
rc = SockSelect("r.","w.","e.")
do i = 1 to r.0           /* display sockets ready for read          */
    say "socket" r.i "is ready for reading."

That SockSelect() call can be invoked as:

rc = SockSelect("r.","w.","")


rc = SockSelect("r.","w.",)

The function call SockSelect(, , , x) results in the program pausing for x seconds.

Note: SockSelect() interfaces with the C function select().