|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-17 16:05 UTC] djgrrr+phpbugs at p2p-network dot net
Description: ------------ when using stream_socket_client() with the flags (STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT), the async connection does not obey the timeout parameter. Also, when the connection does time out (after around 3 minutes) it does not set the eof flag; although it does return false if you try to read from the connection, it would also make a lot of sense if the eof flag was also set on the resource, so calls to feof() return true. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 14:00:02 2025 UTC |
<?php $host = 'tcp://72.232.216.58:56004'; $sock = stream_socket_client($host, $errno, $err, 5, (STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT)); stream_set_blocking($sock, false); while (isset($sock)) { $r = array($sock); $w = $e = NULL; stream_select($r, $w, $e, 1, 0); if (count($r) > 0) { echo "Ready to read:\n"; foreach($r as $rr) { $md = stream_get_meta_data($rr); var_dump($md, feof($rr), fgets($rr)); fclose($rr); unset($sock); echo $host."\n"; } } } ?> The above code should cause the stream_select to return a readable connection after 5 seconds (in reality it takes around 3 minutes), which when read from will return false, indicating its a failed connection attempt. It would be nice if eof was set on the stream, because the stream technically is at its end (although i'm not sure if that would affect the use of stream_select or not).