I'm trying to work with sockets and I have such problem
In code example:
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,self.listen_address+'\0')
I have error
AttributeError: 'module' object has no attribute 'SO_BINDTODEVICE'
On Linux machine this attribute is OK but on FreeBSD trere are no any SO_* attributes in module IN
. What port should I install to resolve this problem on FreeBDS machine?
Python versions on Linux tested: 2.5.4 and 2.6.4; on FreeBSD: 2.5.5
I can't find anything about this module in my book, and googling keyword IN
looks like seamless ...
update:
I can only bind to address, not to device.
>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> s.bind(("eth0",3040))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1, in bind
socket.gaierror: [Errno -2] Name or service not known
>>> s.bind(("192.168.33.152",3040))
>>> s.close()
update 2:
... but I'm working with broadcast packets. I'm trying to write daemon which acts like DHCP server. If I bind to address would I catch broadcast packets? And if I'll set promiscuous mode on?