Is it possible, through the standard Java APIs, to tell if a portable computer is connected to the network or not?

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:

  1. Try to create a URL to one of the X IP's.
  2. 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.
  3. Use RMI for the above.
  4. ???
There could be many ways to implement this, depending on your architecture, your network type, and what you are trying to accomplish.