Bug #3719: Reading from socket doesn't return all data

From: Date: Fri, 03 Mar 2000 14:19:26 +0000
Subject: Bug #3719: Reading from socket doesn't return all data
Groups: php.dev 
Request: Send a blank email to php-dev+get-16345@lists.php.net to get a copy of this message
From: woecherl@mlcomputing.de Operating system: Windows NT 3.51 and SuSE Linux 6.2 PHP version: 3.0.15 PHP Bug Type: Misbehaving function Bug description: Reading from socket doesn't return all data 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

« previous php.dev (#16345) next »