I've created a simple socket php 5.3 script where the server script calls...
socket_select($read_set, $write_set, $exception_set, 2);
...in a loop. I'm using non-blocking sockets and the script is running on a Win7 machine.
The problem: This function blocks the script for 2 seconds. This means the 4th parameter ($tv_sec) does cause this block.
My question: What's the differencebetween $tv_sec
or $tv_usec
? What does $tv_usec
do?
Function description on the php manual:
socket_select(array&$read, array&$write, array&$ex, int $tv_sec[,int $tv_usec=0])
tv_sec: The tv_sec and tv_usec together form the timeout parameter. The timeout is 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: no description
The $tv_usec parameter is used when you want the socket_select() function to timeout after a given amount of microseconds. This, for example, is useful if you want the select to timeout after less than 1 second.