This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Sockets and Internet Protocols and the fly likes How to know whenever my system connects to internet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "How to know whenever my system connects to internet?" Watch "How to know whenever my system connects to internet?" New topic
Author

How to know whenever my system connects to internet?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Aug 18, 2009
Posts: 174

Making a socket connection to over the internet and determining the success?
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Oct 27, 2005
Posts: 19679
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know whenever my system connects to internet?