From:             ml at foofree dot sk
Operating system: Windows XP
PHP version:      5.2.5
PHP Bug Type:     Network related
Bug description:  feof() does not detect timeout on socket

Description:
------------
>From docs:

"Returns TRUE if the file pointer is at EOF or an error occurs (including
socket timeout); otherwise returns FALSE."

...

"If a connection opened by fsockopen() wasn't closed by the server, feof()
will wait until a timeout has been reached to return TRUE. The default
timeout value is 60 seconds. You may use stream_set_timeout() to change
this value."



feof() dows not wait and returns TRUE instead of FALSE if timeout reached
(server does not closed connection and there is no data in timeout time
slot).

* server does not closed connection,
* timeout wa reached

Reproduce code:
---------------
$s = stream_socket_client('tcp://www.php.net:80', $errno, $errstr, 10,
STREAM_CLIENT_CONNECT);

stream_set_timeout($s, 4);

$response = '';
while (feof($s) !== TRUE) {

   if (($foo = @fread($s, 1024 * 8)) === FALSE) return NULL;
   $response = $response . $foo;
};

print "OK";

Expected result:
----------------
prints "OK" approx. in 4 seconds

Actual result:
--------------
hangs forever

-- 
Edit bug report at http://bugs.php.net/?id=43782&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43782&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43782&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43782&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43782&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43782&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43782&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43782&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43782&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43782&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43782&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43782&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43782&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43782&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43782&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43782&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43782&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43782&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43782&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43782&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43782&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43782&r=mysqlcfg

Reply via email to