An application I am developing contains something like the following:
$this->socket = fsockopen($server, $port, $errnum, $errstr, "60");
...
while (!feof($this->socket)) {
$char = fgets($this->socket,1);
if (($char == "\n") || ($char == "\r"))
return $buffer;
}
$buffer .= $char;
}
return $buffer;
This works fine upto php-4.2.x. However, I've recently built and
installed php-4.3.0pre2 and now the above code appears to hang.
Substituting fread in place of fgets solves the problem. I know that
fgets is supposed to be 'binary safe' as of php-4.3 but I'm not sure if
this could be causing the above problem.
Does anyone know of any changes to fgets in php-4.3.0 which might be
causing this? Are there any reasons why I should not use fread instead
of fgets here?
Also, I am looking at using something like:
$status = socket_get_status($this->socket);
if ($status["unread_bytes"] <= 0)
return false;
However, $status["unread_bytes"] always returns 0 until the first call
to fgets($this->socket). Is this right? I'd like to check the status of
the socket before I try to read from it.
Thanks,
Stephen Grier
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php