In the php documentation listed here there's an indication that the function uses the read, error and write array values as refference but I have failed to find anywhere what is actually changed in those values.
I wrote a simple 'server' I use now and I noted that when the mentioned function fails to see any data on the polled clients, then it changes the array and renders it unusable to poll again. This is my code:
<php - all socket creation binding and listening above..
socket_set_nonblock($mysock);
$w = $e = array();
$clients = array($mysock);
do {
$temp_client = @socket_accept($mysock);
if ($temp_client != FALSE)
$clients[] = $temp_client;
$clients_backup = $clients;
$select_socket = socket_select($clients,$w,$e,0);
if (($select_socket !== FALSE) AND ($select_socket != 0)) {
foreach ($clients as $value) {
$input = socket_read($value,1024,PHP_BINARY_READ);
echo $input;
}
}
$clients = $clients_backup;
} while(TRUE);
When testing this consider that the first connection is not handled.. I have no idea why (would very much thank elightment) this code is a strip of what I'm developing and there it works ok. The socket_select issue remains the same in both codes.
Basically If I do not make that backup of the clients array, it doesn't work. The error: "no resource arrays were passed to select" is seen since the array doesn't have the socket resource after socket_select first checks a connection with no data to read.