getprotobyname
Description
The getprotobyname of Network for PHP get protocol number associated with protocol name.
Syntax
getprotobyname( string $protocol ): int|false
Parameters
protocol
The protocol name.
Return
Returns the protocol number, or false on failure.
Examples
1 · protocol
<? $protocol = 'tcp'; $return = getprotobyname($protocol); echo $return; ?>
6
2
<? $array = ['ip', 'icmp', 'igmp', 'ggp', 'ipv4', 'st', 'tcp', 'cbt', 'egp', 'igp', 'bbn-rcc', 'nvp', 'pup', 'argus', 'emcon', 'xnet', 'chaos', 'udp', 'mux', 'dcn', 'hmp', 'prm', 'xns-idp', 'trunk-1', 'trunk-2', 'leaf-1', 'leaf-2', 'rdp', 'irtp', 'iso-tp4', 'netblt', 'mfe-nsp', 'merit-inp', 'dccp', '3pc', 'idpr', 'xtp', 'ddp', 'idpr-cmtp', 'tp++', 'il', 'ipv6', 'sdrp', 'ipv6-route', 'ipv6-frag', 'idrp', 'rsvp', 'gre', 'dsr', 'bna', 'esp', 'ah', 'i-nlsp', 'swipe', 'narp', 'mobile', 'tlsp', 'skip', 'ipv6-icmp', 'ipv6-nonxt', 'ipv6-opts', 'cftp', 'sat-expak', 'kryptolan', 'rvd', 'ippc', 'sat-mon', 'visa', 'ipcv', 'cpnx', 'cphb', 'wsn', 'pvp', 'br-sat-mon', 'sun-nd', 'wb-mon', 'wb-expak', 'iso-ip', 'vmtp', 'secure-vmtp', 'vines', 'ttp', 'nsfnet-igp', 'dgp', 'tcf', 'eigrp', 'ospf', 'sprite-rpc', 'larp', 'mtp', 'ax.25', 'ipip', 'micp', 'scc-sp', 'etherip', 'encap', 'gmtp', 'ifmp', 'pnni', 'pim', 'aris', 'scps', 'qnx', 'a/n', 'ipcomp', 'snp', 'compaq-peer', 'ipx-in-ip', 'vrrp', 'pgm', 'l2tp', 'ddx', 'iatp', 'stp', 'srp', 'uti', 'smp', 'sm', 'ptp', 'isis', 'fire', 'crtp', 'crudp', 'sscopmce', 'iplt', 'sps', 'pipe', 'sctp', 'fc', 'rsvp-e2e-ignore', 'mobility-header', 'udplite', 'mpls-in-ip', 'manet', 'hip', 'shim6', 'wesp', 'rohc']; for($i = 0; $i < count($array); ++$i) { $protocol = $array[$i]; $return = getprotobyname($protocol); echo "$return: $protocol\n"; } ?>
0: ip 1: icmp 2: igmp 3: ggp 4: ipv4 5: st 6: tcp 7: cbt 8: egp 9: igp 10: bbn-rcc 11: nvp 12: pup 13: argus 14: emcon 15: xnet 16: chaos 17: udp 18: mux 19: dcn 20: hmp 21: prm 22: xns-idp 23: trunk-1 24: trunk-2 25: leaf-1 26: leaf-2 27: rdp 28: irtp 29: iso-tp4 30: netblt 31: mfe-nsp 32: merit-inp 33: dccp 34: 3pc 35: idpr 36: xtp 37: ddp 38: idpr-cmtp 39: tp++ 40: il 41: ipv6 42: sdrp 43: ipv6-route 44: ipv6-frag 45: idrp 46: rsvp 47: gre 48: dsr 49: bna 50: esp 51: ah 52: i-nlsp 53: swipe 54: narp 55: mobile 56: tlsp 57: skip 58: ipv6-icmp 59: ipv6-nonxt 60: ipv6-opts 62: cftp 64: sat-expak 65: kryptolan 66: rvd 67: ippc 69: sat-mon 70: visa 71: ipcv 72: cpnx 73: cphb 74: wsn 75: pvp 76: br-sat-mon 77: sun-nd 78: wb-mon 79: wb-expak 80: iso-ip 81: vmtp 82: secure-vmtp 83: vines 84: ttp 85: nsfnet-igp 86: dgp 87: tcf 88: eigrp 89: ospf 90: sprite-rpc 91: larp 92: mtp 93: ax.25 94: ipip 95: micp 96: scc-sp 97: etherip 98: encap 100: gmtp 101: ifmp 102: pnni 103: pim 104: aris 105: scps 106: qnx 107: a/n 108: ipcomp 109: snp 110: compaq-peer 111: ipx-in-ip 112: vrrp 113: pgm 115: l2tp 116: ddx 117: iatp 118: stp 119: srp 120: uti 121: smp 122: sm 123: ptp 124: isis 125: fire 126: crtp 127: crudp 128: sscopmce 129: iplt 130: sps 131: pipe 132: sctp 133: fc 134: rsvp-e2e-ignore 135: mobility-header 136: udplite 137: mpls-in-ip 138: manet 139: hip 140: shim6 141: wesp 142: rohc
Links
Related
Network
- checkdnsrr
- closelog
- dns_check_record
- dns_get_mx
- dns_get_record
- fsockopen
- gethostbyaddr
- gethostbyname
- gethostbynamel
- gethostname
- getmxrr
- getprotobynumber
- getservbyname
- getservbyport
- header
- header_register_callback
- header_remove
- headers_list
- headers_sent
- http_response_code
- inet_ntop
- inet_pton
- ip2long
- long2ip
- openlog
- pfsockopen
- setcookie
- setrawcookie
- socket_get_status
- socket_set_blocking
- socket_set_timeout
- syslog