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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux