我尝试让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))
我们将不胜感激!