public static boolean isPortUnavailableForTcp(final int port) {
    try (final ServerSocket serverSocket = new ServerSocket()) {
      serverSocket.setReuseAddress(true);
      serverSocket.bind(new InetSocketAddress(port));
      serverSocket.close();
      return false;
    } catch (IOException ex) {
      LOG.trace(String.format("Failed to open port %d for TCP", port), ex);
    }
    return true;
  }
Is port unavailable for tcp.

@param port the port
@return true if the port is unavailable for TCP
util/src/main/java/org/hyperledger/besu/util/NetworkUtility.java