Re: Re: How to find out if PC is online

From: Date: Mon, 01 Dec 2003 17:00:59 +0000
Subject: Re: Re: How to find out if PC is online
References: 1 2 3  Groups: php.windows 
Request: Send a blank email to php-windows+get-22252@lists.php.net to get a copy of this message
Hi, Good idea except that gethostbyaddr just query a dns server for a translation of server name to an ip adress, no matter if the host is "up" or not. You've not access to the ping command, you can try to access another service on your machine ie: http, echo, date ... For example, using http, you just have to create a file on your http server root called isup.txt which contain just one char: 1 (or anything else) and the above code will warn you if host is down:
        $ok= empty(file_get_contents("http://XXX.XXX.XXX.XXX/isup.txt"));
        if( $ok )
                echo "The host is up\n";
        else
                echo "The host is DOWN !!\n";
Eric At 17:03 01/12/2003, Jan Hrebenar wrote:
thanks, good idea J.Veenhuijsen wrote:
Try : gethostbyaddr (PHP 3, PHP 4 ) Get the Internet host name corresponding to a given IP address string gethostbyaddr (string ip_address) Returns the host name of the Internet host specified by ip_address. If an error occurs, eturns ip_address. See also gethostbyname(). Jochem Jan Hrebenar wrote:
Hello All, I`d like to make script which will detect if my computer at IP xxx.xxx.xxx.xxx is online. I try to use system("ping") but this function is not allowed on server. Can somebody tell me if exist any other way to do this? Pls excuse my english
-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.windows (#22252) next »