Dear people,

I have a question about how gethostbyaddr does its resolving. Say, I have
the following snippet of code:

use Socket;
use strict;

my ($port, $iaddr) = sockaddr_in (getpeername ($this->{'socket'}));
$this->{'host'} = gethostbyaddr ($iaddr,AF_INET) || inet_ntoa($iaddr);
$this->{'host_ip'} = inet_ntoa($iaddr);

This code is used in an Perl IRC server.

I have noticed, however, that often the host of users upon connection gets
set to inet_ntoa($iaddr), because apparently gethostbyaddr ($iaddr,AF_INET)
fails somehow.

When I then do, say, a manual traceroute on the IP address given by
inet_ntoa($iaddr), it DOES resolve, and I get the accompanying hostaddress.

My question is: why does gethostbyaddr not resolve properly (whereas
traceroute does,) and if so, can I use a better method of resolving the
host-address?

Much obliged,

- Mark

        System Administrator Asarian-host.org

---
"If you were supposed to understand it,
we wouldn't call it code." - FedEx

_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to