The gethostbyaddr function translates a network address to its corresponding names. : gethostbyaddr « Network « Perl






The gethostbyaddr function translates a network address to its corresponding names.

   

Format: gethostbyaddr(ADDRESS, DOMAIN_NUMBER);

#!/bin/perl
$address=pack("C4", 127,0,0,1);
($name, $aliases,  $addrtype, $length, @addrs) = gethostbyaddr($address,2);
($a, $b, $c, $d) = unpack ( 'C4', $addrs[0]);
print "Hostname Is $name and the Internet address Is $a.$b.$c.$d.\n";

   
    
    
  








Related examples in the same category

1.The gethostbyaddr function searches the file /etc/hosts for the host name.