此函数联系系统的名称解析服务,返回类型为ADDRTYPE的主机ADDR的信息列表,如下所示-($name,$aliases,$addrtype,$length,@addrs)
@addrs数组包含打包二进制地址的列表。在标量context中,返回主机地址。
以下是此函数的简单语法-
gethostbyaddr ADDR, ADDRTYPE
此函数在错误时返回undef,否则在scalrcontext中返回主机名,在错误时返回空列表,否则在列表context中返回主机记录。
以下是显示其基本用法的示例代码-
#!/usr/bin/perl use Socket; $iaddr=inet_aton("127.1"); # or whatever address $name =gethostbyaddr($iaddr, AF_INET); print "Host name is $name\n";
执行上述代码后,将产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/perl/perl-gethostbyaddr.html
来源:LearnFk无涯教程网
Host name is ip-50-62-147-141.ip.secureserver.net
这一章《Perl - gethostbyaddr函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持