mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
03.41.2007 a22acf0c877f931dcce85305b6a5232c805e407b
opends/src/server/org/opends/server/util/SetupUtils.java
@@ -246,17 +246,18 @@
  /**
   * Returns {@code true} if the provided port is free and we can use it,
   * {@code false} otherwise.
   * @param hostname the host name we are analyzing.
   * @param port the port we are analyzing.
   * @return {@code true} if the provided port is free and we can use it,
   * {@code false} otherwise.
   */
  public static boolean canUseAsPort(int port)
  public static boolean canUseAsPort(String hostname, int port)
  {
    boolean canUseAsPort = false;
    ServerSocket serverSocket = null;
    try
    {
      InetSocketAddress socketAddress = new InetSocketAddress(port);
      InetSocketAddress socketAddress = new InetSocketAddress(hostname, port);
      serverSocket = new ServerSocket();
      if (!isWindows())
      {
@@ -273,7 +274,7 @@
       */
      try
      {
        new Socket("localhost", port);
        new Socket(hostname, port);
        canUseAsPort = false;
      } catch (IOException ioe)
@@ -300,6 +301,18 @@
  }
  /**
   * Returns {@code true} if the provided port is free and we can use it,
   * {@code false} otherwise.
   * @param port the port we are analyzing.
   * @return {@code true} if the provided port is free and we can use it,
   * {@code false} otherwise.
   */
  public static boolean canUseAsPort(int port)
  {
    return canUseAsPort("localhost", port);
  }
  /**
   * Returns {@code true} if the provided port is a priviledged port,
   * {@code false} otherwise.
   * @param port the port we are analyzing.