• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Detect new NetworkInterfaces dynamically at runtime?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic