If my network interface was down then kernel give me interrupt or any signal?
if my interface was down then my software must know, I don't want poll any fd.
the kernel has to give signal or interrupt to my software.
Is this Possible? how?
If my network interface was down then kernel give me interrupt or any signal?
if my interface was down then my software must know, I don't want poll any fd.
the kernel has to give signal or interrupt to my software.
Is this Possible? how?
What do you mean by "down"? "ifconfig eth0 down" or "someone pulled the wire out"?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
In both case.
It may be that the hardware gives an interrupt for the "wire got disconnected", it almost certainly doesn't when you tell it "shut yourself down" [ok, so maybe some of that requires sending commands to the network device and those commands return an interrupt to say "Ok, I've done that now, anything else you want me to do?"]
Also, if you want to check the connectivity between your machine and the rest of the world, you would have to do polling [by sending a ping to some machine that you know should be reachable] - just because YOUR machine has the wire connected to a HUB doesn't meant that the hub is connected to anything.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
is there some type of architecture or mechanism which told me about this type of event?
I'm not sure. There is a message in the system event log, so you may be able to trace that down.
But I still ask: What is the purpose of ONLY detecting that the device is down, when that is pointless, and what really needs to be known is that the system is connected to the network properly or not - which involves sending a ping or some such to another machine!
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
cause my s/w is one type of monitor which monitor all the devices of system and report the administrator for devise failure. and my s/w must be lightweight so that's why instate of polling interrupt is best.
But if you poll once a second, I can assure you that anything but a very low-end machine (something less than a 33MHz 486) there would be measurable difference in performance - and it would tell you MORE about the system.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I agree with Mats, you can easily write a task that polls your network card/switch or any network interface and then log/report if there is any detected fault. I have done it on a point to point radio that I developed (the task runs once a second and checks a five port switch status). The only problem is if your network interface is down and you need to send an IP message to the administrator....
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Just as an addendum to this, one of my systems (the one I use the most, unfortunately) has some kind of problem whereby I actually have to leave ping running in the background all the time (at it's default rate, maybe once or twice a second) in order to keep my net connection up properly, and this does not noticably hamperer either the connection speed or place any "strain" on the processor/resources.
One of these days I should track this down, since the other installation on the exact same computer with the same netlink does not have that problem...but anyway, they are both linux and matsp is correct, there is no point in just polling the device because the network could be down or unreachable and such a check will not be able to tell, since polling the network device does not mean polling the network.
Use ping.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge