Forum Moderators: coopster
The only way i can do it is with an iframe, so the frame can load late or not at all while my page completes. but i need the contents IN my page.
Many Many thanks for any help you can offer.
I have been playing around with stream_set_timeout without luck, it just doesnt seem to do anything whatever time out i set
$fp = fopen("http://www.example.com", "r");
stream_set_timeout($fp, 1);
$res = fread($fp, 2000);
$info = stream_get_meta_data($fp);
fclose($fp);
if ($info['timed_out']) {
$related = "unavailable";
} else {
$related = file_get_contents("http://www.example.com");
}
can anyone show me what im doing wrong, thanks
I have now tried this but it still just timeout after 60 seconds.
$file = "http://www.example.com/foo.html";
$fp= fopen($file, 'rb' );
if (!$fp) {die ("Failed to open $file, errors: $errstr ($errno)<br>\n");
}
$timelimit = "2";
stream_set_blocking($fp, FALSE );
stream_set_timeout($fp, 1);
$start= microtime();
usleep(100);
$chunk= fread($fp, 10); //chunks, packets are limited anyhow
ob_flush();
if (microtime() + $start > $timelimit){
$related = "";}
else {
$related = file_get_contents($file);
}
Thanks
thers not a lot more i can say, but why my script wont work is beyond me.
I must be doing something wrong as i never seem to get stream_set_timeout to work.
I have tried fsockopen with a timeout but the server does respond but is just slow with the stream.
Thanks