Re: Bug #1739: fread() hangs while trying to read from a socket
| From: | Sascha Schumann | Date: | Mon, 19 Jul 1999 20:37:33 +0000 |
| Subject: | Re: Bug #1739: fread() hangs while trying to read from a socket | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-8739@lists.php.net to get a copy of this message | ||
On Mon, Jul 19, 1999 at 08:20:28PM -0000, danbeck@scott.net wrote:
> From: danbeck@scott.net
> Operating system: Linux 2.0.32 (RedHat 5.2)
> PHP version: 3.0 Latest CVS (19/07/1999)
> PHP Bug Type: Misbehaving function
> Bug description: fread() hangs while trying to read from a socket
>
> This problem has existed since about 3.0.9. It's supposedly
> been fixed in one way or another, but it keeps cropping up...
> consistantly. What I'm doing is attempting to read data from a
> socket using the following methodology:
>
> while (!feof($this->socket)){
> $buffer .= fread( $this->socket, 1);
> }
>
> What happens is that php hangs for exactly 16 seconds every single time.
>
> Even if I just do a:
>
> $buffer = fread( $this->socket, 1024);
>
> it also hangs for the same amount of time.
>
> But... if I try to read a number of bytes less than or equal to
> the number of bytes available, it returns instantly with the
> data from the socket:
>
> $buffer = fread( $this->socket, 2);
Well, 1 is less than or equal to 2. Following your logic, it
should work then.
Where is the problem? In which way does the peer send the data?
Reading single bytes from a HTTP server works for me.
--
Regards,
Sascha Schumann
Consultant