|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-22 08:31 UTC] sniper@php.net
[2005-03-20 18:00 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
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.