I use socket.recvmsg()
to get the data and the sender's IP address of a UDP broadcast message. This works fine on Linux, but this method is not available on Windows (Python 3.3). How can I obtain the sender's IP address?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.