php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3719 Reading from socket doesn't return all data
Submitted: 2000-03-03 09:19 UTC Modified: 2000-08-19 12:10 UTC
From: woecherl at mlcomputing dot de Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.15 OS: Windows NT 3.51 and SuSE Linux 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: woecherl at mlcomputing dot de
New email:
PHP Version: OS:

 

 [2000-03-03 09:19 UTC] woecherl at mlcomputing dot de
Hi folks,

look at the following code:
<?php
$url = "http://192.168.2.40:80/give/me/that/data?some=param";
$res = "";
$maxread = 4096;
$fp = fopen($url, "r");
if ($fp > 0)
{
	while (!feof($fp))
	{
		$res .= fread($fp, $maxread);
	}
	fclose($fp);
} else
{
	die("err: no socket connection to dispatcher");
}
echo strlen($res) . '<hr>' . $res;
?>

This code should read the result of a query to a server application, but it does not quite - it reads most, but not all data. The server sends (in my test scenario) 115310 bytes, but PHP receives only about 95000. Ok, the server application is self-written, but both IE 5 and NN 4.7 read all the results, but not this PHP script - it terminates too early. I could not figure out why.

If the server waits for say half a second after the last send() until it terminates the connection, PHP reads all the data (via local fast ethernet), so there seems to be a synchronization issue. Since I do not know how the browsers do their reads, I have no good idea on how one might change the PHP code to get this stuff working.

Best regards

Michael Woecherl

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-05 11:30 UTC] sas at cvs dot php dot net
I cannot reproduce that locally. Please provide more information on the type of the server you use (i.e. does it send the data in multiple chunks, timing, source code). A tcpdump of the session would also be useful.
 [2000-08-19 12:10 UTC] joey@php.net
No feedback.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC