Is there any way that java can detect that I have just plugged in a wired-network, and monitor it's bandwith? (I'm using linux, if that matters)
+2
A:
For the sake of simplicity and without using native code, you could try to using java.net.NetworkInterface with polling, so every X seconds you trigger a network interface enumeration in order to see if there are new interfaces.
dfa
2009-04-24 13:11:41
thanks :) just what I was looking for ;)
Johannes
2009-04-24 13:20:53
A:
You can run the program
/sbin/ip monitor
And monitor its output using a pipe or whatever.
It will tell you when
- New network interfaces are configured
- Network interfaces go up and down because the network becomes ready / not ready (this typically works by detecting an ethernet carrier or wifi access point)
The output is somewhat confusing but should be parseable.
MarkR
2009-04-25 17:59:48