Hello. I am trying to learn how fopen and stream_set_timeout work together. I wrote this little script, to try and force a timeout in fopen (to see if it works) by setting the timeout seconds to zero (with the line stream_set_timeout($fp,0); ) can somebody tell me if what I am doing is correct and/or what might be the problem in my code and/or how can I force the thing to timeout so that I can test this script. Thanks in advance.
$whole = "";
$fp = fopen($url, "r");
stream_set_blocking($fp, FALSE );
stream_set_timeout($fp,0);
$info = stream_get_meta_data($fp);
while(!feof($fp) && !$info['timed_out']){
$content = fgets($fp,1400);
$whole .= $content;
$info = stream_get_meta_data($fp);
}
if($info['timed_out']){
echo "time out!";
}
fclose($fp);
$whole = "";
$fp = fopen($url, "r");
stream_set_blocking($fp, FALSE );
stream_set_timeout($fp,0);
$info = stream_get_meta_data($fp);
while(!feof($fp) && !$info['timed_out']){
$content = fgets($fp,1400);
$whole .= $content;
$info = stream_get_meta_data($fp);
}
if($info['timed_out']){
echo "time out!";
}
fclose($fp);