List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:February 3 2011 9:51pm
Subject:bzr commit into wex-installer-1.0 branch (reggie.burnett:298)
View as plain text  
#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:iggy@stripped

  298 Reggie Burnett	2011-02-03
      change PortIsAvailable to check for active listeners instead of active connections

    modified:
      WexInstaller/Panels/ServerConfigPanel2.cs
=== modified file 'WexInstaller/Panels/ServerConfigPanel2.cs'
=== modified file 'WexInstaller/Panels/ServerConfigPanel2.cs'
--- a/WexInstaller/Panels/ServerConfigPanel2.cs	2010-11-30 14:52:06 +0000
+++ b/WexInstaller/Panels/ServerConfigPanel2.cs	2011-02-03 21:51:47 +0000
@@ -8,6 +8,7 @@
 using System.Globalization;
 using System.Net.NetworkInformation;
 using System.ServiceProcess;
+using System.Net;
 
 namespace WexInstaller.Panels
 {
@@ -49,24 +50,18 @@
 
         private bool PortIsAvailable(int port)
         {
-            bool isAvailable = true;
-
             // Evaluate current system tcp connections. This is the same information provided
             // by the netstat command line application, just in .Net strongly-typed object
             // form.  We will look through the list, and if our port we would like to use
             // in our TcpClient is occupied, we will set isAvailable to false.
             IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
-            TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();
-
-            foreach (TcpConnectionInformation tcpi in tcpConnInfoArray)
-            {
-                if (tcpi.LocalEndPoint.Port == port)
-                {
-                    isAvailable = false;
-                    break;
-                }
-            }
-            return isAvailable;
+
+            // test active listeners
+            IPEndPoint[] endPoints = ipGlobalProperties.GetActiveTcpListeners();
+            foreach (IPEndPoint endPoint in endPoints)
+                if (endPoint.Port == port) return false;
+
+            return true;
         }
 
         public override void Activate()


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110203215147-g2u83kghg6u36a58.bundle
Thread
bzr commit into wex-installer-1.0 branch (reggie.burnett:298) Reggie Burnett3 Feb