Gentoo Archives: gentoo-user

From: Meino Christian Cramer <Meino.Cramer@×××.de>
To: gentoo-user@l.g.o, reader@×××××××.com
Subject: Re: [gentoo-user] Re: OT: How to check for an existing ethernet link ?
Date: Sun, 01 Oct 2006 16:02:29
Message-Id: 20061001.175622.95061499.Meino.Cramer@gmx.de
1 From: reader@×××××××.com
2 Subject: [gentoo-user] Re: OT: How to check for an existing ethernet link ?
3 Date: Sun, 01 Oct 2006 10:27:34 -0500
4
5 > Meino Christian Cramer <Meino.Cramer@×××.de> writes:
6 >
7 > > Hi,
8 > >
9 > > sorry for being off topic, but I think, folks of this list have the
10 > > knowledge to answer my question and I have no idea who to ask else...
11 > >
12 > > I need to check from within a C-program whether the computer, the
13 > > program is running on (OS: Linux), is connected to the ethernet. The
14 > > program is running under root privilege. Before doing anything else
15 > > with eth0, I want to check the link-LED of the ethernet card...so to
16 > > say.
17 > >
18 > > I sthere any "legal" way to do such things under Linux?
19 >
20 > A common way is to use the result of a single ping to known up host,
21 > in an if/else control block.
22 >
23 > --
24 > gentoo-user@g.o mailing list
25 >
26
27 The problem is a little different here. In principle ping'ing is a
28 good way to test the availablity of a net-connection. No doubt!
29
30 But in my case I have to avoid *ANY* timeouts (wayting for an answer
31 or another timeout for example: the timeout of "gethostbyname()") if
32 possible. My program has to react AS FAST AS POSSIBLE on error
33 conditions. So if I can check the availability of a net-connection
34 without actually accessing the net and wait for an answer (or an error
35 condition) it would be the best solution. The fact that I am urged to
36 use UDP makes things even more difficult. I know that simply
37 attaching the computer to a switch/hub and removing the net-plug there
38 makes the link check worthless ... but I want to try every possibility
39 to find out, whether there is the chance to contact the "target"
40 (wrong word...sorry) without trying exactly that (or similiar),
41 haveing to wait for an answer (or error condition) and paying the
42 panalty of timeouts then.
43
44 If there is any net-programming hyper-guru out there who knows some
45 special tricks to achieve the shortest possible time of
46 reaction...here is someone who will thank her/him very much for any
47 help in advance ! :)
48
49 keep hacking!
50 mcc
51
52 --
53 gentoo-user@g.o mailing list

Replies

Subject Author
[gentoo-user] Re: Re: OT: How to check for an existing ethernet link ? Mick <michaelkintzios@×××××.com>