#include <quintus/quintus.h>
     int QP_select(wid,read_fds,write_fds,except_fds,timeo)
     int    wid;
     fd_set *read_fds;
     fd_set *write_fds;
     fd_set *except_fds;
     struct timeval *timeo;

Wait until I/O is ready on a file descriptor or until a timeout occurs


This is a more general version of QP_wait_input(), which is compatible with the system call select(2). It waits for any of read_fds to be ready for reading, or write_fds to be ready for writing, or except_fds to have an exceptional command pending, or for the timeout period timeo to elapse, whichever comes first. Callbacks on other descriptors are handled while waiting. However, no callbacks on any of the desciptors specified in read_fds, write_fds, and except_fds are called, rather QP_select() returns immediately.

Return Values

the number of descriptors in the bit mask, QP_SUCCESS if a timeout occurred or QP_ERROR if an error occurred.

Windows Caveats

Under Windows, there is a special SOCKET data type, which is different from file descriptors. The arguments to QP_select() are sets of such sockets, not file descriptors, exactly like the WinSock select() function.

QP_select() is not interruptible by ^C. For this reason, calling QP_select() with infinite timeout is probably a bad idea. If called with infinite timeout and if there are no open sockets, then QP_select() will return immediately, indicating a timeout.

With a finite timeout value but no open sockets, QP_select() will use the Win32 Sleep() function to perform a (non-interruptible) sleep.

See Also

QP_wait_input(), QP_add_*()