views:

784

answers:

2

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
thanks :) just what I was looking for ;)
Johannes
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