Java HTTP Port Find isLocalPortFree(final int port)

Here you can find the source of isLocalPortFree(final int port)

Description

is Local Port Free

License

Open Source License

Declaration

private static boolean isLocalPortFree(final int port) 

Method Source Code


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

import java.io.IOException;
import java.net.ServerSocket;

public class Main {
    private static boolean isLocalPortFree(final int port) {
        try {// w w w.  ja  va2s. co  m
            new ServerSocket(port).close();
            return true;
        } catch (final IOException e) {
            return false;
        }
    }
}

Related

  1. isHostAvailable(final String host, final int port)
  2. isHostReachable(String host, int port, int connTimeout)
  3. isListening(String host, int port)
  4. isLivereloadAvailable(int port)
  5. isLocalPortAvailable(final int port)
  6. isLocalPortOccupied(int portNum)
  7. isLocalPortUsed(int port)
  8. isLoclePortUsing(int port)
  9. isMulticastSupported(NetworkInterface pNif)