You are here: [newbie help] « All PHP « IT news, forums, messages
[newbie help]

Posted by Ben Jamieson on 10/21/05 21:26

Hi all, I need some help, as this one is driving me mad.... if anyone
could assist, I would be hugely appreciative!

OK, Here's my code:

<?php

$query_timeout= 4 ;
$url="http://my.test.com";
$fp = fopen ($url, 'rb');
$chunk = fread($fp, 2000);
stream_set_timeout($fp, $query_timeout);
$status = stream_get_meta_data($fp);
fclose($fp);

if ($status['timed_out']) {
echo 'Connection timed out!';
} else {
echo "Contents: ". $chunk;
}

?>


The URL I am accessing is often unavailable, as the server goes down a
lot. Shouldn't this script simply give up after 4 seconds? It doesn't.
It times out after ~2 minutes.

Every time, after 2 minutes, I see on screen:

Contents:

(nothing else, as the URL couldn't be opened cos the server is down.)

Surely I should be seeing:

Connection Timed Out

Any clues as to what I am doing wrong here?

TIA

Ben

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация