public static boolean verifyConnection(String host, int port)
    {
        Socket socket = null;
        try
        {
            socket = new Socket(host, port);
            socket.setReuseAddress(true);
            socket.setSoLinger(true, 0);
            boolean isConnected = socket.isConnected();
            return isConnected;
        }
        catch (UnknownHostException e)
        {
            logger.warn("{}:{} is still down", host, port);
            return false;
        }
        catch (IOException e)
        {
            logger.warn("{}:{} is still down", host, port);
            return false;
        }
        finally
        {
            try
            {
                if (socket != null)
                {
                    socket.close();
                }
            }
            catch (IOException e)
            {
                logger.warn("{}:{} is still down", host, port);
            }
        }
    }
public static boolean verifyConnection ( String host , int port ) { Socket socket = null ; try { socket = new Socket ( host , port ) ; socket . setReuseAddress ( true ) ; socket . setSoLinger ( true , 0 ) ; boolean isConnected = socket . isConnected ( ) ; return isConnected ; } catch ( UnknownHostException e ) { logger . warn ( "{}:{} is still down" , host , port ) ; return false ; } catch ( IOException e ) { logger . warn ( "{}:{} is still down" , host , port ) ; return false ; } finally { try { if ( socket != null ) { socket . close ( ) ; } } catch ( IOException e ) { logger . warn ( "{}:{} is still down" , host , port ) ; } } }
@param host
@param port
@return