fread() behaviour

From: Date: Thu, 20 Nov 2008 01:29:34 +0000
Subject: fread() behaviour
Groups: php.general 
Request: Send a blank email to php-general+get-283580@lists.php.net to get a copy of this message
I'm trying to understand something about fread(). I'm using fread() on an incoming socket stream that will send, for example, 26630 characters: while ( ($buf=fread($read[$i], 8192)) != '' ) { $sock_data .= $buf; usleep(1000); echo "."; } echo ","; As soon as the socket client sends the data, immediately the server will echo: ................................................................................................................................................ Then wait nearly a minute, and echo: , So my question is, why does fread wait if there is nothing more to read? Shouldn't it return immediately? (That's what I want.) And as for the delay, it's there so that if the incoming data is a little slow, it has time to catch up with fread. Thanks. ...Rene

« previous php.general (#283580) next »