Perl getprotoent 函数

  • 描述

    getprotoent 此函数返回有效协议列表中的下一个条目:($name,$aliases,$protocol_number)。
  • 句法

    以下是此函数的简单语法-
    
    getprotoent
    
  • 返回值

    此函数对错误返回undef,否则返回标量上下文中的协议编号,并在列表上下文中返回错误协议记录上的空列表(名称,别名,协议编号)。
  • 示例

    以下是显示其基本用法的示例代码-
     
    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 = st
    Aliases = ST
    Protocol Number = 5
    Name = tcp
    Aliases = TCP
    Protocol Number = 6
    Name = egp
    Aliases = EGP
    Protocol Number = 8
    Name = igp
    Aliases = IGP
    Protocol Number = 9
    Name = pup
    Aliases = PUP
    Protocol Number = 12
    Name = udp
    Aliases = UDP
    Protocol Number = 17
    Name = hmp
    Aliases = HMP
    Protocol Number = 20
    Name = xns-idp
    Aliases = XNS-IDP
    Protocol Number = 22
    Name = rdp
    Aliases = RDP
    Protocol Number = 27
    Name = iso-tp4
    Aliases = ISO-TP4
    Protocol Number = 29
    Name = dccp
    Aliases = DCCP
    Protocol Number = 33
    Name = xtp
    Aliases = XTP
    Protocol Number = 36
    Name = ddp
    Aliases = DDP
    Protocol Number = 37
    Name = idpr-cmtp
    Aliases = IDPR-CMTP
    Protocol Number = 38
    Name = ipv6
    Aliases = IPv6
    Protocol Number = 41
    Name = ipv6-route
    Aliases = IPv6-Route
    Protocol Number = 43
    Name = ipv6-frag
    Aliases = IPv6-Frag
    Protocol Number = 44
    Name = idrp
    Aliases = IDRP
    Protocol Number = 45
    Name = rsvp
    Aliases = RSVP
    Protocol Number = 46
    Name = gre
    Aliases = GRE
    Protocol Number = 47
    Name = esp
    Aliases = IPSEC-ESP
    Protocol Number = 50
    Name = ah
    Aliases = IPSEC-AH
    Protocol Number = 51
    Name = skip
    Aliases = SKIP
    Protocol Number = 57
    Name = ipv6-icmp
    Aliases = IPv6-ICMP
    Protocol Number = 58
    Name = ipv6-nonxt
    Aliases = IPv6-NoNxt
    Protocol Number = 59
    Name = ipv6-opts
    Aliases = IPv6-Opts
    Protocol Number = 60
    Name = rspf
    Aliases = RSPF CPHB
    Protocol Number = 73
    Name = vmtp
    Aliases = VMTP
    Protocol Number = 81
    Name = eigrp
    Aliases = EIGRP
    Protocol Number = 88
    Name = ospf
    Aliases = OSPFIGP
    Protocol Number = 89
    Name = ax.25
    Aliases = AX.25
    Protocol Number = 93
    Name = ipip
    Aliases = IPIP
    Protocol Number = 94
    Name = etherip
    Aliases = ETHERIP
    Protocol Number = 97
    Name = encap
    Aliases = ENCAP
    Protocol Number = 98
    Name = pim
    Aliases = PIM
    Protocol Number = 103
    Name = ipcomp
    Aliases = IPCOMP
    Protocol Number = 108
    Name = vrrp
    Aliases = VRRP
    Protocol Number = 112
    Name = l2tp
    Aliases = L2TP
    Protocol Number = 115
    Name = isis
    Aliases = ISIS
    Protocol Number = 124
    Name = sctp
    Aliases = SCTP
    Protocol Number = 132
    Name = fc
    Aliases = FC
    Protocol Number = 133
    Name = mobility-header
    Aliases = Mobility-Header
    Protocol Number = 135
    Name = udplite
    Aliases = UDPLite
    Protocol Number = 136
    Name = mpls-in-ip
    Aliases = MPLS-in-IP
    Protocol Number = 137
    Name = manet
    Aliases = 
    Protocol Number = 138
    Name = hip
    Aliases = HIP
    Protocol Number = 139
    Name = shim6
    Aliases = Shim6
    Protocol Number = 140
    Name = wesp
    Aliases = WESP
    Protocol Number = 141
    Name = rohc
    Aliases = ROHC
    Protocol Number = 142