如何使用python套接字编程通过多类型转换发现WiFi网络上的所有设备?下面是我尝试的代码。
import socket
data='<?xml version="1.0" encoding="utf-8"?>......</soap:Envelope>'
def run(group= '239.255.255.250', port=1900):
MULTICAST_TTL = 20
s= socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
s.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, MULTICAST_TTL)
s.connect((group, port))
s.sendall(data)
d = s.recv(1024)
print("data:"+d)
run()