forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r170674 - /forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java
Date Tue, 17 May 2005 22:01:14 GMT
Author: rgardler
Date: Tue May 17 15:01:14 2005
New Revision: 170674

URL: http://svn.apache.org/viewcvs?rev=170674&view=rev
Log:
add method for checking if a port is free

Modified:
    forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java

Modified: forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java?rev=170674&r1=170673&r2=170674&view=diff
==============================================================================
--- forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java (original)
+++ forrest/trunk/tools/eclipse/src/org/apache/forrest/eclipse/actions/Utilities.java Tue
May 17 15:01:14 2005
@@ -20,7 +20,10 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FilenameFilter;
+import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.Socket;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -64,6 +67,25 @@
 
 		return result;
 	}
+	
+	/**
+	 * Checks to see if the port is available. 
+	 * @return true if the port is available
+	 */ 
+	static public boolean isPortFree(int portNumber) {
+		try {
+			Socket echoSocket = new Socket("localhost", portNumber);
+			echoSocket.close();
+			return false;
+		} catch (UnknownHostException e) {
+			return true;
+			
+		} catch (IOException e) {
+			return true;
+			
+		}	
+		
+	}; 
 
 	/**
 	 * @param cmdString



Mime
View raw message