|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32058 stream_set_timeout() appears to do nothing of value
Submitted: 2005-02-21 23:14 UTC Modified: 2005-03-20 18:00 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: alan at ridersite dot org Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 4.3.10 OS: BSD
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-02-21 23:14 UTC] alan at ridersite dot org
It appears to me that stream_set_timout() does not do anything of value.  

You can set it prior to a while loop; but, it does nothing to help you exit the loop if the time expires. e.g.,
stream_set_timeout($fp, 20);	

$status = socket_get_status($fp);
while (!feof($fp) && !$status['timed_out']) {
    $chunk = fread($fp, 10000);
    $length = strlen($chunk);
    $html_str .= $chunk;
    $status = socket_get_status($fp);
} //end while, fetching data

If fread() hangs up, the script hangs.  

You can do exactly the same thing by simply keeping track of elapsed time in the loop. 

Set stream_set_blocking($fp, FALSE ) so fread() keeps going and the loop continues until the elapsed time expires. 



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-22 08:31 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

 [2005-03-20 18:00 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 21:01:27 2024 UTC