本文整理匯總了Python中socket.IPPROTO_ICMPV6屬性的典型用法代碼示例。如果您正苦於以下問題:Python socket.IPPROTO_ICMPV6屬性的具體用法?Python socket.IPPROTO_ICMPV6怎麽用?Python socket.IPPROTO_ICMPV6使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類socket
的用法示例。
在下文中一共展示了socket.IPPROTO_ICMPV6屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_getprotobyname
# 需要導入模塊: import socket [as 別名]
# 或者: from socket import IPPROTO_ICMPV6 [as 別名]
def test_getprotobyname(self):
'''Tests _socket.getprotobyname'''
#IP and CPython
proto_map = {
"icmp": _socket.IPPROTO_ICMP,
"ip": _socket.IPPROTO_IP,
"tcp": _socket.IPPROTO_TCP,
"udp": _socket.IPPROTO_UDP,
}
#supported only by IP
if is_cli:
proto_map.update(
{"dstopts": _socket.IPPROTO_DSTOPTS,
"none": _socket.IPPROTO_NONE,
"raw": _socket.IPPROTO_RAW,
"ipv4": _socket.IPPROTO_IPV4,
"ipv6": _socket.IPPROTO_IPV6,
"esp": _socket.IPPROTO_ESP,
"fragment": _socket.IPPROTO_FRAGMENT,
"nd": _socket.IPPROTO_ND,
"icmpv6": _socket.IPPROTO_ICMPV6,
"routing": _socket.IPPROTO_ROUTING,
"pup": _socket.IPPROTO_PUP, #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21918
"ggp": _socket.IPPROTO_GGP, #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21918
})
for proto_name, good_val in proto_map.items():
temp_val = _socket.getprotobyname(proto_name)
self.assertEqual(temp_val, good_val)
#negative cases
bad_list = ["", "blah", "i"]
for name in bad_list:
self.assertRaises(_socket.error, _socket.getprotobyname, name)