I want to find out if an application server is running or not on a remote computer. I do this with the following code:
Socket localSocket = null;
try {
localSocket = new Socket( serverName, serverPort );
localSocket.close();
return ServerStatus.UP;
} catch ( IOException e ) {
//
} finally {
if ( localSocket != null ) {
try {
localSocket.close();
} catch ( IOException e ) {
Log.LOGGER.log( Level.SEVERE, "Socket could not be closed", e );
}
}
}
return ServerStatus.DOWN;
It works fine on Windows XP (32 bit) and on Windows 7 Professional (64 bit). On Windows 7 Ultimate (64 bit) it does not work at all.
On Windows 7 Ultimate (64 bit) the localSocket can be made in the following cases:
- the remote computer is in the network and connected but the application server on the remote computer is not running.
- the remote computer is in the network and connected but switched off.
- the remote computer is in the network and the network cable on the remote computer is not connected.
On Windows 7 Ultimate (64 bit) the localSocket can not be made in the following cases:
- the remote computer is not in the network.
- the network calbe on my computer is not connected.
Many thanks for any ideas of how to solve this problem.