File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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: 19649
    
  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?
 
Similar Threads
Communication between Java and Mainframe System
Thread Safe
java program that connects to a webpage
interfacing with internet explorer
firewall for cable modem