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

Re: [MacPerl] gethostbyaddr



On 7/8/98 at 2:18 PM, Strider <Strider@baka.com> wrote:

>
>I'm working on a problem with our DNS servers, Apache, and PERL.
>
>$host = gethostbyaddr("x.x.x.x",AF_INET);
>print "$host\n";
>
>This code (when an IP is substituted) doesn't return anything- I think I've
>followed all instructions properly. gethostbyname doesn't want to work,
>either. It returns data, but it doesn't return a resolved hostname or IP no
>matter what I feed it- it just returns what I gave it.
>
It doesn't return anything (actually, it returns undef) because you're passing it a string and it wants a 4 byte numerical address. You need to use inet_aton to convert the string:

$host = gethostbyaddr(inet_aton("x.x.x.x"), AF_INET);
print "$host\n"; # now prints hostname

See perlfunc and perlipc for details.

>Anyway, I thought I'd ask here what I could possibly be screwing up before
>I move on...
>
>- Strider
>
j

--
#!/usr/bin/perl
$dot="\x2e";$lt="\x3c";$gt="\x3e";$at="\x40";
print "J Mignault ${lt}mignault${at}nytimes${dot}com${gt}\n";
$quote = qq("They'll get my perl when they pry it from my cold, dead /usr/local/bin." --Randy Futor in  <1992Sep13.175035.5623\@tc.fluke.COM>);



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch