Java HTTP Port checkHostAvailability(String host, int port)

Here you can find the source of checkHostAvailability(String host, int port)

Description

check Host Availability

License

Open Source License

Declaration

public static boolean checkHostAvailability(String host, int port) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.net.Socket;

public class Main {
    public static boolean checkHostAvailability(String host, int port) {
        try (Socket s = new Socket(host, port)) {
            s.getOutputStream().write(0);
            return true;
        } catch (IOException ex) {
            /* ignore */
        }// w w w.  j  av  a2  s  .  c o m
        return false;
    }
}

Related

  1. checkHostPort(String connectionString)
  2. checkIfPortAvailable(int port)
  3. create(final int[] ports)
  4. create(String scheme, String rawUserInfo, String host, int port, String rawPath, String rawQuery, String rawFragment)