php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alan at ridersite dot org
New email:
PHP Version: OS:

 

 [2005-02-21 23:14 UTC] alan at ridersite dot org
Description:
------------
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;
    sleep(2);
    $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. 

 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-22 08:31 UTC] sniper@php.net
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] sniper@php.net
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: Fri Mar 29 11:01:29 2024 UTC