tags:

views:

49

answers:

1

Is there any way in Java to receive event notifications whenever link state changes on a computer (connected, disconnected, up, down, etc)? Thanks!

+1  A: 

There is no platform-independent mechanism which accomplishes this in Java. However, you can use JNI to do it. For example, Windows allows you to poll (or be notified of) network interface states using the Network Location Awareness (NLA) API.

BigZig
Thanks BigZig. Another two APIs I found are Windows [Network List Manager][1] and [ISensNetwork][2]. They both can actually push link state notifications, but NLM only supports Vista and above, and ISensNetowrk can't work reliably, according to some posts online :( [1]: http://msdn.microsoft.com/en-us/library/aa370803(VS.85).aspx [2]: http://msdn.microsoft.com/en-us/library/aa377384(v=VS.85).aspx
wwh37
Wondering why SO doesn't render my links correctly. Try again: <a href="http://msdn.microsoft.com/en-us/library/aa370803(VS.85).aspx">Network List Manager</a> and <a href="http://msdn.microsoft.com/en-us/library/aa377384(v=VS.85).aspx">ISensNetwork</a>.
wwh37