socket_select()
socket_select - Runs the select() system call on the given arrays of sockets with a specified timeout
Syntax
int socket_select (
array &$read,
array &$write,
array &$except,
int $tv_sec,
int $tv_usec)
Arguments
- read - The sockets listed in the read array will be watched to see if characters become available for reading (more precisely, to see if a read will not block - in particular, a socket resource is also ready on end-of-file, in which case a socket_read() will return a zero length string).
- write - The sockets listed in the write array will be watched to see if a write will not block.
- except - The sockets listed in the except array will be watched for exceptions.
- tv_sec - The tv_sec and tv_usec together form the timeoutparameter. The timeoutis an upper bound on the amount of time elapsed before socket_select() return. tv_sec may be zero, causing socket_select() to return immediately. This is useful for polling. If tv_sec is NULL (no timeout), socket_select() can block indefinitely.
- tv_usec
Description
socket_select() accepts arrays of sockets and waits for them to change status. Those coming with BSD sockets background will recognize that those socket resource arrays are in fact the so-called file descriptor sets. Three independent arrays of socket resources are watched.
Version
PHP 4.1.0, 5
Return value
On success socket_select() returns the number of socket resources contained in the modified arrays, which may be zero if the timeout expires before anything interesting happens. On error FALSE is returned. The error code can be retrieved with socket_last_error().