Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Detect new NetworkInterfaces dynamically at runtime?  RSS feed

 
Riffle Chris
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hey everybody good morning,

Are there any good solutions or libraries for detecting dynamically at run-time when a new NetworkInterface gets created - due to things such as the end-user physically plugging in a new Ethernet rj45 cable into their NIC(s)?

Does java provide any listeners to use that would receive an event being fired when a new NetworkInterface has been created / made available?

Right now, I have to run a thread and call NetworkInterface.getNetworkInterfaces() at my predefined interval of seconds throughout the lifetime of the program (which is wasting cpu/memory resources)

I also have to do this to detect when a NetworkInterface has been "taken away" / made unavailable.

Thanks!
 
thushara wijeratna
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this is possible via some jni on Linux (and possibly on other platforms). basically Linux provides a PF_NETLINK socket call where setting the netlink_family to NETLINK_ROUTE allows you to get notifications of all sorts, including interface additions/deletions.
On a Linux shell, do a "man 7 netlink" - there is an example as well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!