#24782 [Opn->Bgs]: fread'ing with large buffers from slow pages does not work
ID: 24782
Updated by: wez@php.net
Reported By: odarcan at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Network related
Operating System: win xp
PHP Version: 4.3.2
New Comment:
http://www.php.net/manual/en/function.flush.php
Previous Comments:
------------------------------------------------------------------------
[2003-07-24 16:25:54] odarcan at hotmail dot com
i already know that the data received from the pointer can be less than
given buffersize (EOF or size whichever comes first), and believe me
this has absolutely NOTHING to do with my bug report.
I have used php with network functions for 2.5 years and this is the
first time i've come across this,
read carefully.
the 'page' is a slow opening php script
the body of the page is not returned when doing a single fread, only
headers are returned.
only when putting several freads after eachother OR when sleeping
before a single fread, is the body fetched.
keep up the food work..
------------------------------------------------------------------------
[2003-07-23 19:35:18] wez@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
reading from sockets will give you a packet sized chunk which can be
less than the buffer size you requested.
This is documented in the manual and has been the behaviour since
sockets were introduced to PHP.
Note that 4.3.0 and 4.3.1 were broken in that they would block your
whole script to try to fulfill your request - breaking other peoples
scripts.
------------------------------------------------------------------------
[2003-07-23 19:22:46] odarcan at hotmail dot com
Description:
------------
$pcstring=fread ($pcpointer,1000);
$pcstring.=fread ($pcpointer,1000);
$pcstring.=fread ($pcpointer,1000);
$pcstring.=fread ($pcpointer,1000);
$pcstring.=fread ($pcpointer,1000);
is NOT the same as
$string=fread ($pcpointer,5000);
at least not in slow opening pages (as php scripts doing calculations)
the second code only gives the headers while skipping the rest while
the first shows echoed results from the php script (as it did with
previous versions of php)
putting a sleep(1); before the fread also solves this (for me at
least).
sleep(1);
$string=fread ($pcpointer,5000);
it has taken me 5 days to figure out what was wrong, FIVE DAYS...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24782&edit=1
Thread (5 messages)