fgets() hang up?
| From: | Jon | Date: | Tue, 28 Nov 2000 19:34:39 +0000 |
| Subject: | fgets() hang up? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27615@lists.php.net to get a copy of this message | ||
When using a persistant connection, why does this code hang up on the
fifth loop iteration (the socket connected to only returns four lines,
so obviously its not quitting the loop when it should)
// defined earlier on in the class:
var $socket; // this is set and connected to when the object
// is created (pfsockopen / fsockopen )
function readAll()
{
$returnData = Array();
while ( !feof( $this->socket ) )
{
echo ".";
flush();
$thisLine = fgets( $this->socket, 128 );
if ( $thisLine != "" )
$returnData[] = $thisLine;
else break;
}
return $returnData;
}
// The socket is connecting, cause if I loop 4 times specifically, it
// works fine.. it gets caught up on the fifth line..
// the echo "." /flush() is simply for me to see where it's getting
// caught
Thanks! -- Jon