PHP 4.0 Bug #6266: fgets() never timeout used in a HTTP connection
| From: | joel dot jacobson at mobigym dot se | Date: | Sun, 20 Aug 2000 18:59:27 +0000 |
| Subject: | PHP 4.0 Bug #6266: fgets() never timeout used in a HTTP connection | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-29947@lists.php.net to get a copy of this message | ||
From: joel.jacobson@mobigym.se
Operating system: Linux 2.2.15
PHP version: 4.0.1pl2
PHP Bug Type: Misbehaving function
Bug description: fgets() never timeout used in a HTTP connection
The example below sometimes hangs my PHP script because of my slow Internet connection:
<?php
$fp = fopen ( 'http://www.php.net/',
'r' );
while ( !feof($fp) )
$data .= fgets ( $fp, 1024 );
fclose ( $fp );
?>
The fgets function is the problem. There is no way to speficy a timeout limit for this function. I
think it's necessary in some cases. It's very anyoing when the PHP script just hangs. A
web browser like Netscape tries to download the same document many times. That's a very good
solution. But it's not possible to do the same in PHP at the moment. I would be pleased if you
could fix this. Maybe by let the programmer specify a optional third timeout parameter to the fgets
function.