public static boolean isSocketAlive ( String host , int port ) { boolean socketAlive = false ; Socket socket = null ; try { socket = new Socket ( host , port ) ; socketAlive = socket . isConnected ( ) ; } catch ( Throwable t ) { // do nothing } finally { if ( socket != null ) { try { socket . close ( ) ; } catch ( IOException e ) { // do nothing } } } return socketAlive ; }
Checks if the socket of specified host and port is alive .