🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.perl
Article #256

Re: gethostbyaddr()

#256
From: Chris Labanowski
Date: Fri, 16 May 1997 08:25
42 lines
1967 bytes
Alan Ghafour (alan@gdansk.sprint.pl) wrote:
: Probuje zrobic gethostbyaddr() i za ... mi nie wychodzi :-(
: Moze ktos przesledzi ponizszy kawalek i powie gdzie jest blad ?

: #! /usr/bin/perl

: $host="pingwin.ds2.pg.gda.pl";
: $addr="153.19.170.112";

: #############################################
: # Resolving na podstawie nazwy dziala poprawnie !

: ($a,$b,$c,$d)=unpack("C4",gethostbyname($host));
: $IP=join(".",$a,$b,$c,$d);
: print $host,"\n", $IP, "\n";

: #############################################
: # A na podstawie adresu nie :-(

: # Ani tak ...
: $name=gethostbyaddr($addr,AF_INET);
: print $name, "\n";

: # Ani tak
: $addr=pack("C4",$a,$b,$c,$d);
: $name=gethostbyaddr($addr,AF_INET);
: print $name,"\n";
a sprobouj tak ( u mnie dziala):
$addr="148.81.83.5";
($h1,$h2,$h3,$h4)=split(/\./,$addr,4);
$packed=pack('C4',$h1,$h2,$h3,$h4);
($name,$aliases,$type,$len,@addr)=gethostbyaddr($packed,2);
print "$name\n";
 
 a w pozostalych zmiennych masz reszte danych....
 pewnie da sie to prosciej napisac, ale tak jest czytelnie :)
 KL

:  __ __ __  _ _  _ ___   _  _ ___ ___   ______         Alan Ghafour 
: (_  |_)|_) | |\ |  | __ |\ | |_   |   [/~~~~\]    Network Administrator
: __) |  | \ | | \|  |    | \| |__  |    |_()_|     alan@gdansk.sprint.pl
:                                                 http://www.sprint.pl/~alan
Technical Details
Message-ID: <5lh5mg$nak@info.nask.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!ict.pwr.wroc.pl!news.nask.pl!gwx.gazeta.pl!chrisl
References: <Pine.GSO.3.96.970515105108.18403A-100000@netra.gdansk.sprint.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!ict.pwr.wroc.pl!news.nask.pl!gwx.gazeta.pl!chrisl
From: chrisl@gazeta.pl (Chris Labanowski)
Newsgroups: pl.comp.lang.perl
Subject: Re: gethostbyaddr()
Date: 16 May 1997 08:25:52 GMT
Organization: Gazeta Wyborcza
Lines: 43
Message-ID: <5lh5mg$nak@info.nask.pl>
References: <Pine.GSO.3.96.970515105108.18403A-100000@netra.gdansk.sprint.pl>
NNTP-Posting-Host: gwx.gazeta.pl
X-Newsreader: TIN [version 1.2 PL2]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit