Hi,
I've written a simple script,that checks whether some service is up or down on a host, the "strange" thing is it works correct with all services I've tried, but the 'www' service is just always up on any host even if it doesn't exist, I'm obviously doing something wrong, but what?
Below is an example code:
<?php
$sTarget = "www.tools.ccghhgcom";
function IsHostUp($sTarget,$iPort=80,$dTimeout=30){
$rSocket = @fsockopen($sTarget,$iPort,$iErrorNr,$sErrStr,$dTimeout);
if(!$rSocket)
{
return("$sErrStr($iErrorNr)");
}
fclose($rSocket);
return(true);
}
$mResult = IsHostUp(gethostbyname($sTarget));
if($mResult!==true)
{
echo"$sTarget is <b>down</b><br>$mResult";
}
else
{
echo"$sTarget is <b>up</b>";
}
?>