我使用socket.recvmsg()
来获取UDP广播消息的数据和发送者的IP地址。这在Linux上运行良好,但这种方法在Windows上不可用(Python 3.3)。如何获取发件人的IP地址?
from socket import *
fd = socket(AF_INET, SOCK_DGRAM)
fd.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
fd.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
data, _, _, addr = fd.recvmsg(4096) # <- how to achieve this without recvmsg?
host, upd_port = addr