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

Re: [MacPerl] Re: MacPerl-Digest V1 #73



Zachary Burnham wrote:
> 
> Greetings.
> 
> I'm trying to create a chunk of code that will take an IP and return the
> appropriate hostname for that IP.
> Simple, right?
> Not hardly.
> 
> This is what I have so far:
> -----------------
> #!perl -w
> use Socket;
> use Sys::Hostname;
> my($ip, $dns);
> #$ip will be available from previous code
> 
> 
> print((gethostbyaddr($ip,4)),"\n");
> -----------------
> 
> 
> 
> I got 4 for ADDRTYPE from the incredibly poorly documented gethostbyname()
> function.  The above code does not work at all.  It gives the following
> error:
> 

You should be using the constants imported from the Socket module for
ADDRTYPE.  In this case, AF_INET or PF_INET, which, I believe, are
equivalent to each other.

Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org