Andrei solved it. It is because socket_select() mangles the passed arrays
so when you re-enter the call with the mangled $read array you are now
only checking the sockets that happened to trigger the first time through.
It means you actually have to do:
$read = array($sock1,$sock2);
$copy = $read;
while($num=socket_select($copy, $write=NULL, $except=NULL, NULL)) {
for($i=0; $i<$num; $i++) {
usleep(500);
$msg = socket_read($copy[$i],1024);
echo "[$i] ".strlen($msg)."\n";
}
$copy = $read;
}
So you save the original array of sockets to pass back in. This is why
the C API has FD_ISSET() to check the result of a select(). I really
don't like this current behaviour of socket_select(). It will confuse the
hell out of anybody coming at this from a C background.
-Rasmus
On Sun, 2 Jun 2002, Philip Olson wrote:
> I only get [0], never [1]. Did about 40 tries.
>
> latest CVS
> ./configure --enable-sockets
>
> If you need more info, let me know.
>
> Regards,
> Philip Olson
>
>
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php