php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24782 fread'ing with large buffers from slow pages does not work
Submitted: 2003-07-23 19:22 UTC Modified: 2003-07-24 17:45 UTC
From: odarcan at hotmail dot com Assigned:
Status: Not a bug Package: Network related
PHP Version: 4.3.2 OS: win xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: odarcan at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-07-23 19:22 UTC] 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...



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-23 19:35 UTC] 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-24 16:25 UTC] 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-24 17:45 UTC] wez@php.net
Either that or you need to specify more precisely what is really happening...

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Mar 22 12:01:27 2019 UTC