Passing argument to setsockopt(socket.SOL_SOCKET, IN.SO_BINDTODEVICE, intr)

Richard Taylor rjt-usenet at thegrindstone.me.uk
Wed Apr 21 05:36:53 EDT 2004


Hi

Does anyone know the correct way to pass the 'device' argument to setsockopt
with the SO_BINDTODEVICE flag?

I have tried various methods:

setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,"eth0")
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,inet_aton("eth0"))
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,struct.pack("s","eth0"))
setsockopt(socket.SOL_SOCKET,IN.SO_BINDTODEVICE,struct.pack("p","eth0"))

None of these work. I just get a "socket.error: (19, 'No such device')".

I do have an "eth0" device :-)

Many thanks

Richard








More information about the Python-list mailing list