I found multiple answers that suggest using the SO_REUSEPORT socket option when multiple UDP clients need to listen for broadcasts on the same port. However I'm getting an error that this option is not available. Using python 2.7
from socket import *
s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
try:
s.bind(('', MYPORT))
except:
print "Error connecting to the UDP stream."
Traceback (most recent call last):
File "qsorder.py", line 119, in <module>
s.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
NameError: name 'SO_REUSEPORT' is not defined
I've tried SO_REUSEADDR and it does not give an error but only one client receives broadcasts. Any idea how to work around this?