473,414 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Raw socket when interface down.

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
1 5456
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Konerding | last post by:
Hello, I have written an app which opens a TCP connection to a server and uses a protocol to communicate with it. Specifically, I've written a python IMD client for the molecular dynamics...
4
by: Bryan Olson | last post by:
Here's the problem: Suppose we use: import socket f = some_socket.makefile() Then: f.read() is efficient, but verbose, and incorrect (or at least does not play will with others);
4
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects...
4
by: Alex Martinoff | last post by:
Using the org.postgresql.Driver JDBC driver is it possible to connect to Postgres using a unix domain socket instead of a TCP socket (so you don't have to start the postmaster with -i)? Using a TCP...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
7
by: Ole | last post by:
Hi, I'm going to develop a socket communication between an instrument (running CE 5.0 with Compact Fraework V2) and a PC. As the instrument should only connect to one PC at a time I believe that...
4
by: seets375 | last post by:
Hi, I have two ethernet interfaces on my system, with IPs assigned to the interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 - 20.20.20.20 ). I'm connecting these interfaces to...
10
by: Hendrik van Rooyen | last post by:
While doing a netstring implementation I noticed that if you build a record up using socket's recv(1), then when you close the remote end down, the recv(1) hangs, despite having a short time out...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.