• 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

How to know whenever my system connects to internet?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to know if my system is connected to internet, through a program?
How to know whenever my system connects to internet?

I suppose there should be a port which a program will continuously listen & so on... But I am new to networking & not really worked on it.

Example, just like in Windows, a program (tool) activates when ever we insert a LAN cable or switch on wireless & tries to find out networks. Something like that...

Thanks.


PS: Not sure if it belongs General Computing or here.
 
Ranch Hand
Posts: 174
Java ME Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Making a socket connection to over the internet and determining the success?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Zandis Murāns wrote:Making a socket connection to over the internet and determining the success?



Thanks Zandis.
I thought of this option but this implies that I make this call say every minute or so to know if my system came in network or not...

Can it be done by a kind of "push" mechanism?
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try a ping of sorts (using InetAddress.isReachable) to a server on the Internet, but that will also fail if the remote host is down.

As for the notification Windows provides, that may be available but through JNI only, or it may not be available at all. You can also check out java.net.NetworkInterface but I'm not sure it can help you out with this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic