A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / SocketUtil.java
index dac0f05..39f97f5 100644 (file)
@@ -1,14 +1,14 @@
 /**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
+ Copyright (c) 2000, 2002 IBM Corp. and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
 
-Contributors:
-    IBM Corporation - Initial implementation
-    Vicente Fernando - www.alfersoft.com.ar
-**********************************************************************/
+ Contributors:
+ IBM Corporation - Initial implementation
+ Vicente Fernando - www.alfersoft.com.ar
+ **********************************************************************/
 package net.sourceforge.phpdt.internal.debug.core;
 
 import java.io.IOException;
@@ -20,25 +20,30 @@ import java.util.Random;
  * Utility class to find a port to debug on.
  */
 public class SocketUtil {
-       private static final Random fgRandom= new Random(System.currentTimeMillis());
-       
+       private static final Random fgRandom = new Random(System
+                       .currentTimeMillis());
+
        /**
         * Returns a free port number on the specified host within the given range,
         * or -1 if none found.
         * 
-        * @param host name or IP addres of host on which to find a free port
-        * @param searchFrom the port number from which to start searching 
-        * @param searchTo the port number at which to stop searching
+        * @param host
+        *            name or IP addres of host on which to find a free port
+        * @param searchFrom
+        *            the port number from which to start searching
+        * @param searchTo
+        *            the port number at which to stop searching
         * @return a free port in the specified range, or -1 of none found
         */
-       public static int findUnusedLocalPort(String host, int searchFrom, int searchTo) {
+       public static int findUnusedLocalPort(String host, int searchFrom,
+                       int searchTo) {
 
-               // First look at the five first ports starting on searchFrom  
-               for (int i= searchFrom; i <= searchFrom + 5; i++) {
-                       Socket s= null;
-                       int port= i;
+               // First look at the five first ports starting on searchFrom
+               for (int i = searchFrom; i <= searchFrom + 5; i++) {
+                       Socket s = null;
+                       int port = i;
                        try {
-                               s= new Socket(host, port);
+                               s = new Socket(host, port);
                        } catch (ConnectException e) {
                                return port;
                        } catch (IOException e) {
@@ -52,11 +57,11 @@ public class SocketUtil {
                        }
                }
                // No free port found then look at 5 random ports numbers
-               for (int i= 0; i < 5; i++) {
-                       Socket s= null;
-                       int port= getRandomPort(searchFrom, searchTo);
+               for (int i = 0; i < 5; i++) {
+                       Socket s = null;
+                       int port = getRandomPort(searchFrom, searchTo);
                        try {
-                               s= new Socket(host, port);
+                               s = new Socket(host, port);
                        } catch (ConnectException e) {
                                return port;
                        } catch (IOException e) {
@@ -71,8 +76,8 @@ public class SocketUtil {
                }
                return -1;
        }
-       
+
        private static int getRandomPort(int low, int high) {
-               return (int)(fgRandom.nextFloat() * (high-low)) + low;
+               return (int) (fgRandom.nextFloat() * (high - low)) + low;
        }
 }
\ No newline at end of file