In fact you're wrong. gethostbyaddr is a DNS query tool. The host does not need to be up to be referenced in the DNS database.
The dedicated tool to do that is the ICMP socket type ping
>> if the function responds with anything else than the IP adress then the PC must be online!
Just try:
php -r "echo gethostbyname('XXX.XXX.XXX.XXX');"
with an non existing ip adress.
Regards, Eric
At 20:10 01/12/2003, SolidDigital wrote:
What i meant to say was if gethostbyaddr(ipadress) responds with something else than the ipadress then this PC must be online.
Or am I wrong??
Jocjem
B.A.T. Svensson wrote:And precisly how does the mechnaism with gethostbyaddr(),
e.g. an DNS request, work to be able to resolve the issue
about weather a particular host i online or not?
As far as I know this is not possible. The only thing one might
be able to say after a successfull DNS look up is this-or-that
host has a registered entry in the DNS server. Nothing more can
be deduced.
If I messed something here, please fill me in.
-----Original Message-----
From: J.Veenhuijsen
To: php-windows@lists.php.net
Sent: 2003-12-01 12:53
Subject: Re: How to find out if PC is online
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