Perl 的 gethostbyaddr 使用方法介绍

2015-12-14 0 460
Perl 的 gethostbyaddr 使用方法介绍
# The syntax is (name, altnames, addrtype, len, addrs) = 
# gethostbyaddr (inaddr, inaddrtype); 

#!/usr/local/bin/perl 

$machine ="123.1.1.1"; 
@bytes = split (/\./, $machine); 
$packaddr = pack ("C4", @bytes); 
if (!(($name, $altnames, $addrtype, $len, @addrlist) = gethostbyaddr ($packaddr, 2))) { 
    die ("Address $machine not found.\n"); 
} 
print ("Principal name: $name\n"); 
if ($altnames ne "") { 
    print ("Alternative names:\n"); 
    @altlist = split (/\s+/, $altnames); 
    for ($i = 0; $i < @altlist; $i++) { 
        print ("\t$altlist[$i]\n"); 
    } 
} 

遇见资源网 perl Perl 的 gethostbyaddr 使用方法介绍 http://www.ox520.com/13285.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务