Re: How to detect whether the network interface is up or not.
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jun 2007 13:18:41 +0200
"Jimmy" <lofenee@xxxxxxxxxxxx> writes:
I have a single application server host, and I want to get a daemon run on
it to detect whether the network interface is up or not.
I have tried to build a TCP connection from and to the server itself via the
interface to be detected, hoping the KEEPALIVE may help. But even if I
unplugged the cable from the interface and 'ifconfig' showed it was DOWN,
the connection still appears 'alive'. Using 'ping', it indicated that
outside host is not available, however the 'DOWN' interface was to the
server itself.
I wonder if the 'ioctl' can help to detect such case by getting the status
of the interface.
Does anyone know how to detect such case?
You could use ifconfig or do what ifconfig does (no standard API), but
this is useless information.
As you've noted, a ping to oneself still works even if the interface
is down, because a ping to oneself doesn't need to go thru the
interface. And on the other hand, if an interface is up, this doesn't
mean that you can do anything with it anyways, since the cable could
be disconnected behind the HUB, or some router could be down, so you
cannot communicate to the host you want to communicate anyways.
The only meaningful tests are ping(1), which tells you that packets can
go between your host and the remote one you're interested in, and to
connect to the remote application which tells you that the remote
application is available or not.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
.
- Prev by Date: Re: Changing the shell through a C program
- Next by Date: See How Easily You Can Be Computing Ergonomically
- Previous by thread: BrainBench Unix programming test is BrainDead
- Next by thread: Re: How to detect whether the network interface is up or not.
- Index(es):
Relevant Pages
|
|