tcp_select()
#include "tcp.h" int FD,Block; double Timeout; ... switch (tcp_select(Block, Timeout, &FD)) { case tcp_ERROR: ... an error occurred. case tcp_TIMEOUT: ... handle a timeout case tcp_SUCCESS: ... input is ready on FD }
tcp_select()
is used to determine which file descriptor is ready for
input. It returns 3 status values:
tcp_ERROR
perror(3)
.
tcp_TIMEOUT
tcp_SUCCESS
With Block == tcp_BLOCK
, tcp_select()
will ignore the Timeout parameter,
and simply block until some data is available.
With Block == tcp_POLL
, tcp_select()
will sleep for Timeout seconds, or
until data is available, whichever comes first.