From 41bb1d08f6b88244c679fc6d398c4724336e083b Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 03 May 2007 07:41:18 +0000
Subject: [PATCH] Fix for issues 1231 and 1234 ('start-ds logs are incomplete when we provide an invalid LDAP port' and 'Server should not start when no connection handler can be enabled').

---
 opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java b/opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java
index 45b6e79..1157329 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/SetupUtils.java
+++ b/opendj-sdk/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.

--
Gitblit v1.10.0