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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joel dot jacobson at mobigym dot se
New email:
PHP Version: OS:

 

 [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 02:01:35 2024 UTC