我尝试让 uPNP / ssdp Discovery 在 IPv6 上工作
IPv4 发现工作正常:
uUDP_IP = u'239.255.255.250'
iUDP_PORT = 1900
uMessage = u'M-SEARCH * HTTP/1.1\r\nHOST: %s:%d\r\nMAN: "ssdp:discover"\r\nMX: 5\r\nST: %s\r\n\r\n' % (uUDP_IP, iUDP_PORT, "ssdp:all")
oSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
oSocket.settimeout(10)
oSocket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
oSocket.sendto(uMessage, (uUDP_IP, iUDP_PORT))
但我的 IPv6 版本不起作用
uUDP_IP = u'ff02::f'
iUDP_PORT = 1900
uMessage = u'M-SEARCH * HTTP/1.1\r\nHOST: %s:%d\r\nMAN: "ssdp:discover"\r\nMX: 5\r\nST: %s\r\n\r\n' % (uUDP_IP, iUDP_PORT, "ssdp:all")
oSocket = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
oSocket.settimeout(10)
oSocket.setsockopt(socket.IPPROTO_IPV6, socket.IP_MULTICAST_TTL, 2)
oSocket.sendto(uMessage, (uUDP_IP, iUDP_PORT))
帮助将不胜感激!