#26454 [NEW]: feof and fgets hangs out
From: nunoplopes at sapo dot pt
Operating system: Windows XP - Apache
PHP version: 4.3.4
PHP Bug Type: Sockets related
Bug description: feof and fgets hangs out
Description:
------------
I opened a socket using fsockopen and then I send some data using fputs.
Then I try to read data either using feof of fgets. If the servers returns
2 lines and I call three times the fgets(), the script times out when it
reaches the 30 seconds. If I only call fgets 2 times, everything works
fine.
feof also stops the script execution.
So, I have no way to know if servers' response has ended or not.
Reproduce code:
---------------
Get the code from CVS at:
http://cvs.sourceforge.net/viewcvs.py/phpdocmanager/phpcvsclass/
Or just a small example:
<?
if ($handle = fsockopen ("cvs.php.net", 2401, $errno, $errstr, 30)) {
$text = "BEGIN AUTH REQUEST\n";
$text .= "/repository\n";
$text .= "cvsread\n";
$text .= "A\n";
$text .= "END AUTH REQUEST\n";
fputs ($handle, $text);
fgets($handle); // "I LOVE YOU\n"
fputs ($handle, "version\n");
echo fgets($handle);
echo fgets($handle);
echo fgets($handle);
fclose($handle);
}
?>
Expected result:
----------------
M Concurrent Versions System (CVS) 1.12.2 (client/server)\n
ok
Actual result:
--------------
timeout
--
Edit bug report at http://bugs.php.net/?id=26454&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26454&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26454&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26454&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26454&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26454&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26454&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26454&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26454&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26454&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26454&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26454&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26454&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26454&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26454&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26454&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26454&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26454&r=float
Thread (14 messages)
- nunoplopes at sapo dot pt
- iliaa@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Fbk]: feof and fgets hangs out
- nunoplopes at sapo dot pt#26454 [Fbk->Opn]: feof and fgets hangs out
- wez@php.net#26454 [Opn->Csd]: feof and fgets hangs out