I have a socket according to:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind(('0.0.0.0', 67)) # Listen on port 67
Now, the socket listening on all interfaces at port 67. I wait for some message:
message, address = self.socket.recvfrom(8192) # Blocking
When a message is received, I would like to send a broadcast response at port 68 on the same interface that was receiving the message.
The question is: Is there some way to inspect the message and determine which network interface that was receiving the message, and if it is, how can I send a response and provide that interface for transport?
Running at Windows, Python 3.4.