Java HTTP Port Find ping(String domain, int port)

Here you can find the source of ping(String domain, int port)

Description

ping

License

Open Source License

Declaration

public static final boolean ping(String domain, int port) 

Method Source Code

//package com.java2s;
/*//from w w w  .j  a  v a 2  s  .  c  om
 * Copyright 1999-2004 Alibaba.com All right reserved. This software is the confidential and proprietary information of
 * Alibaba.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Alibaba.com.
 */

import java.io.IOException;

import java.net.Socket;
import java.net.UnknownHostException;

public class Main {

    public static final boolean ping(String domain, int port) {
        boolean result = false;
        Socket socket = null;
        try {
            socket = new Socket(domain, port);
            result = true;
        } catch (UnknownHostException e) {
        } catch (IOException e) {
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (Exception ex) {

                }
            }
        }

        return result;
    }
}

Related

  1. parse(final String desc, final int defaultPort)
  2. parse(String specs, int defaultPort)
  3. parseCommaDelimitedHosts2(String hosts, int port_range)
  4. parseHostPort(String s)
  5. parsePort(String s)
  6. pingServer(String host, Integer port)
  7. randomAvailablePort()
  8. randomFreePort()
  9. randomFreePort()