ID:               40517
 User updated by:  djgrrr+phpbugs at p2p-network dot net
 Reported By:      djgrrr+phpbugs at p2p-network dot net
-Status:           Feedback
+Status:           Open
 Bug Type:         Streams related
 Operating System: Linux 2.6
 PHP Version:      5.2.1
 New Comment:

<?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).


Previous Comments:
------------------------------------------------------------------------

[2007-02-19 09:46:08] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------

[2007-02-17 16:05:43] 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. 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40517&edit=1

Reply via email to