> 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.
Yeah, it's a little confusing for C-Programmers, but I think it is OK to
do it in this way. The manual extra points a big note, that naming is
like in C, but the behaviour can be completely different.
Reverting the removing of the fd_* functions would actually more confuse
the users (again) then leaving a note in the manual ...
Just my 0,02$
Greetings,
Marcel Beerta
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php