Reply to Re: See if there are Internet-connection

Your name:

Reply:


Posted by J.O. Aho on 12/13/06 13:38

The87Boy wrote:
> J.O. Aho skrev:
>> If you have the right to include external files, then you could try to include
>> or open a remote file, if that works you have connection, if not than you
>> don't or the remote machine is down.
>
> What if I check it with more than one server?

Of course the more servers you check against the more reliable you will have,
of course when a servers is down or the path to them has some problem the
longer it will take to run the script.


> What about fsockopen('google.com', 80)

function test_internet() {
if(!$fp=fsockopen('www.google.com', 80)) {
if(!$fp=fsockopen('www.whitehouse.gov', 80)) {
if(!$fp=fsockopen('www.microsoft.com', 80)) {
if(!$fp=fsockopen('www.novell.com', 80)) {
return false;
}
}
}
}
fclose($fp);
return true;
}

if(test_internet()) {
"internet";
} else {
"the internet is dead";
}

Think that should work for you.

--

//Aho

[Back to original 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

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