我的python脚本使用getaddrinfo()来解析地址,然后才能对其进行“bind()”。在
脚本片段:
def fetch_ipv6_address(addr="::1"):
# try to detect whether IPv6 is supported at the present system and
# fetch the IPv6 address of localhost.
if not socket.has_ipv6:
raise Exception("the local machine has no IPv6 support enabled")
addrs = socket.getaddrinfo(addr, 0, socket.AF_INET6, socket.SOCK_RAW, 0x73, socket.AI_PASSIVE)
....
....
sockaddr = fetch_ipv6_address("::1")
RX = socket.socket(socket.AF_INET6, socket.SOCK_RAW, 0x73)
RX.bind(sockaddr)
脚本在执行时引发错误:
^{pr2}$知道getaddrinfo()参数有什么问题吗?在
谢谢!在
如果字符串是long或int,则将
0
作为第二个参数is converted,以便它适合底层API调用支持的ai_servname
字段的格式。在奥托,the docs写下来
如果将
0
替换为None
,它就可以工作了。在相关问题 更多 >
编程相关推荐