描述
此函数返回有效协议列表中的下一个条目:($name,$aliases,$protocol_number)
语法
以下是此函数的简单语法-
getprotoent
返回值
此函数针对错误返回undef,否则返回标量context中的协议编号,并在列表context中返回错误协议记录的空列表(名称,别名,协议编号)。
例
以下是显示其基本用法的示例代码-
#!/usr/bin/perl while(($name, $aliases, $protocol_number) = getprotoent()) { print "Name = $name\n"; print "Aliases = $aliases\n"; print "Protocol Number = $protocol_number\n"; }
执行上述代码后,将产生以下输出-
Name = ip Aliases = IP Protocol Number = 0 Name = hopopt Aliases = HOPOPT Protocol Number = 0 Name = icmp Aliases = ICMP Protocol Number = 1 Name = igmp Aliases = IGMP Protocol Number = 2 Name = ggp Aliases = GGP Protocol Number = 3 Name = ipencap Aliases = IP-ENCAP Protocol Number = 4 . . . Name = udplite Aliases = UDPLite Protocol Number = 136 Name = mpls-in-ip Aliases = MPLS-in-IP Protocol Number = 137 Name = manet Aliases = manet Protocol Number = 138 Name = hip Aliases = HIP Protocol Number = 139 Name = shim6 Aliases = Shim6 Protocol Number = 140
参考链接
https://www.learnfk.com/perl/perl-getprotoent.html
标签:Protocol,Name,Number,无涯,protocol,Perl,getprotoent,Aliases From: https://blog.51cto.com/u_14033984/7024399