Hello lads,
I'm hoping someone here can say me why the following piece of code is not working as expected:
<?php
// Create stream
$sock = stream_socket_client ('tcp://www.google.nl:80', $i_Errno, $s_Errstr, null, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
sleep (1);
$r = $w = $e = array ();
$r [] = $sock;
echo 'selecting..' . PHP_EOL;
$i_Changed = stream_select ($r, $w, $e, null);
print_r ($i_Changed);
I would expect stream_select () to return immediately with $r containing one element (the stream resource). Especially since the scripts halts one second. That should be more than enough to complete the connection attempt. And indeed, the stream is connected since fread and fwrite will succeed. However, stream_select does not agree with me. How come?