Raw socket when interface down.

Mat matsujio at orange.fr
Wed Nov 5 10:37:32 EST 2008


Hi,

I'm trying to use raw sockets in python for a dhcp client. I write this code :

soc = socket.socket(socket.PF_PACKET, socket.SOCK_RAW)
soc.bind(("eth0",0x0800))
data = soc.recv(1024)
print len(data)

It seems to work correctly when interface is up, but when network interface is
down I get this message :
socket.error: (100, 'Network is down')

I look over a lot of C code of dhcp clients. But I didn't find something useful.
I don't how to access the network when interface is down with python. Can
someone helps ?

Thanks !

-- 
Mat




More information about the Python-list mailing list