Status
Not open for further replies.
LOL the result is the same as mine ...

i tried sdfbnsdjkfnskvdkdfgdf.com and result was google is awake !! lol

so i am sure the problem comes from the server because on easyphp localhost its working fine !!
 
UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.

so basically you need to send a small 8 bit buffer for your host to actually attempt a connection

try doing something like:

PHP:
try
    {
        $socket = fsockopen($host,$port,$e_number,$e_string,$timeout);
        fwrite($socket,str_repeat(" ",8));
    }catch(Exception $e)
    {
        //Not a valid domain more than likly!
        return false;
    }

if im right, http is based over RTP connections and not UDP, im not sure if RTP is also connectionless
 
PHP:
<?php
error_reporting(0);
function testurl($host) {
	$page = file_get_contents($host);
	
		if (false === $page)
		{
			return false;
		}
		else
		{
			return true;
		}
}

if (testurl('http://google.com'))
{
	echo 'google is awake';
}
else
{
	echo 'google is not awake';
}

?>
 
he only wants to connect to the location to see if its alive, can you give me a good reason why he should fetch the contents, as he is never going to need them.
 
Well, apparently fsock is not working on his host. So FGC would be an alternative that WILL work.

And he can add filters to the FGC function to make sure that only the first byte is fetched, and not the whole page. He's checking the sites, so even if he were to fetch the whole page, they would be a couple KBytes at most.
 
personally i would create a small application that pings a doamin held within includes, then i would use exec to get connection state

PHP:
$result = exec( "includes/pinger.exe --timeout 30 --host google.com" );
if($result == "0")
{
   //dead
}
 
+1 litewarez.
Either exec or system("ping domain")[if the host is allowing it].
curl can be used but it's complicated[again if the host is allowing it].
 
another way you could do it is.

PHP:
function check_host($host)
{
    if(false !== ($context = get_headers($host,1)))
    {
         /*
             $context will look like so
             Array
             (
                 [0] => HTTP/1.1 200 OK
                 [Date] => Sat, 29 May 2004 12:28:14 GMT
                 [Server] => Apache/1.3.27 (Unix)  (Red-Hat/Linux)
                 [Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT
                 [ETag] => "3f80f-1b6-3e1cb03b"
                 [Accept-Ranges] => bytes
                 [Content-Length] => 438
                 [Connection] => close
                 [Content-Type] => text/html
             )
         */
         return true;
    }
}
that might be a small alternative, and also you can then implement header checks as well
 
Status
Not open for further replies.
Back
Top