示例
以下是显示其基本用法的示例代码-
while(($name, $aliases, $port_number, $protocol_name) = getservent()) {
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Port Number = $port_number\n";
print "Protocol Name = $protocol_name\n";
}
尝试一下
执行结果:
Name = tcpmux
Aliases =
Port Number = 1
Protocol Name = tcp
Name = echo
Aliases =
Port Number = 7
Protocol Name = tcp
Name = echo
Aliases =
Port Number = 7
Protocol Name = udp
Name = discard
Aliases = sink null
Port Number = 9
Protocol Name = tcp
Name = discard
Aliases = sink null
Port Number = 9
Protocol Name = udp