Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to know whenever my system connects to internet?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Making a socket connection to over the internet and determining the success?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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?
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic