Is it possible, through the standard Java APIs, to tell if a portable computer is connected to the network or not?
Created May 4, 2012
Shaun Childers
I suppose the answer is "it depends." Are you speaking about a local network? The entire Internet? In general, there is no "signal" available to tell whether a computer is connected to an active network or not, and no way to tell the difference between a working network and a broken network. You must implement your own protocols to do this.
If you are on a local network and you have X number of IP's associated with portable PC's, you could try a couple of different things:
- Try to create a URL to one of the X IP's.
- Install a program which, once connected, must register itself (e.g. its computer name) with a local server you have created. The server could create a java.net.ServerSocket and the portable computer (client) could create a java.net.Socket and connect to register itself.
- Use RMI for the above.
- ???