php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29449 feof hangs on empty tcp stream
Submitted: 2004-07-29 20:31 UTC Modified: 2004-07-31 22:47 UTC
From: norxh at binnews dot com Assigned:
Status: Closed Package: Network related
PHP Version: 5.0.0 OS: Windows 2000
Private report: No CVE-ID: None
 [2004-07-29 20:31 UTC] norxh at binnews dot com
Description:
------------
When feof is called on an empty tcp stream opened by fsockopen, php will hang indefinitely.

In adition to 5.0.0, I also tested with 5.0.x-dev (Jul 29, 2004 16:30 GMT) and 5.1.x-dev (Jul 29, 2004 14:30 GMT). Each test was run with the cli executable.

When attempting to debug this issue with Zend Studio 3.5, I found stopping execution during this hang will cause php.exe or apache.exe to crash when using local or remote debugging respectively.

Adding:
fwrite($stream, "GET / HTTP1.0\r\n\r\n");
before the call to feof will result in proper execution of the script.

Reproduce code:
---------------
<?
set_time_limit(15);
$stream = fsockopen('www.google.com', 80, $errno, $errstr, 5);
stream_set_timeout($stream, 5);
echo feof($stream) ? 'true':'false';
fclose($stream);
?>

Expected result:
----------------
false

Actual result:
--------------
hang

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-29 21:23 UTC] norxh at binnews dot com
Verified that this does not happen on Linux.
OS: Red Hat Enterprise Linux ES release 3
PHP: 5.0.0
 [2004-07-31 13:56 UTC] wez@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

Please try next snapshot dated after this message.
 [2004-07-31 22:45 UTC] norxh at binnews dot com
Okay, I tried the latest builds.

Linux: Still works fine.
Windows 2000: Works perfectly now.

Thanks Wez. 

PHP5 is shaping up very nicely :)
 [2004-07-31 22:47 UTC] norxh at binnews dot com
closing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 10:01:30 2024 UTC