By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,596 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,596 IT Pros & Developers. It's quick & easy.

Raw socket when interface down.

P: n/a
Mat
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

Nov 5 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 5, 8:37*pm, Mat <matsu...@orange.frwrote:
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
mmm, if the interface is down the n/w subsystem will not send messages
out and if possible also disables reception of messages via that
interface. In your case it is likely that the interface message
reception is also disabled. You need to bring up the interface
(ifconfig eth0 up) before you can read/write any data on that
interface.

-srp

Nov 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.