php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6266 fgets() never timeout used in a HTTP connection
Submitted: 2000-08-20 14:59 UTC Modified: 2000-08-21 10:11 UTC
From: joel dot jacobson at mobigym dot se Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: Linux 2.2.15
Private report: No CVE-ID: None
 [2000-08-20 14:59 UTC] joel dot jacobson at mobigym dot se
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-21 10:09 UTC] stas@php.net
set_socket_timeout function should help you.
 [2000-08-21 10:11 UTC] andrei@php.net
It's socket_set_timeout() actually.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 07:01:31 2024 UTC