#26454 [Opn->Fbk]: feof and fgets hangs out
| From: | iliaa@php.net | Date: | Fri, 28 Nov 2003 22:26:23 +0000 |
| Subject: | #26454 [Opn->Fbk]: feof and fgets hangs out | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51262@lists.php.net to get a copy of this message | ||
ID: 26454
Updated by: iliaa@php.net
Reported By: nunoplopes at sapo dot pt
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Windows XP - Apache
PHP Version: 4.3.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Please try the snapshot that will be generated in about 4 hours (from
the time of this post).
Previous Comments:
------------------------------------------------------------------------
[2003-11-28 15:17:56] nunoplopes at sapo dot pt
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 this bug report at http://bugs.php.net/?id=26454&edit=1