From: thomas at nimstad dot com
Operating system: Win32
PHP version: 4.3.2
PHP Bug Type: Sockets related
Bug description: changed behaviour of fread() ?
Problem:
fread() hangs if not reading exact number of bytes from a socket. worked
previously in 4.3.1.
fread() returns max 1024 bytes even if specifying larger numbers. worked
previously in 4.3.1.
Worked previously (snipped):
$fp = fsockopen("localhost", 5410, $errno, $errstr, 100);
// Send request
if (!fputs($fp, $packet, strlen($packet))) { }
// Read result header
while (!feof($fp)) {
$line = fgets($fp);
if ($line != "\n" && $line != "\r\n") {
$header .= $line;
}
else {
if (preg_match('/Content-Length: (\d+)/i', $header, $matches))
$length = $matches[1];
if (preg_match('/X-Session-Id: (\d*)/i', $header, $matches))
$session = $matches[1];
break;
}
}
// Read result body
$reply = fread($fp, $length);
This hangs the executions until timeout (30 sec).
Have to change the read result body to:
while (!feof($fp) && $length > 0) {
$size = min(1024, $length);
$reply .= fread($fp, $size);
$length -= $size;
}
All examples in documentation and even the PEAR/XML-RPC class states the
"old" way what it looks to me.
What's up? New settings that i'm not aware of?
/Thomas
--
Edit bug report at http://bugs.php.net/?id=24033&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=24033&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=24033&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24033&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24033&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24033&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24033&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24033&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24033&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24033&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24033&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24033&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24033&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24033&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24033&r=gnused