- Timestamp:
- 2009-05-13T14:29:21+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/util/PortFinder.java
r19429 r19432 47 47 * @return the number of an available port. 48 48 */ 49 public int findPortInRange(boolean silent) throws Exception {49 public int findPortInRange(boolean verbose) throws Exception { 50 50 try { 51 51 boolean foundFreePort = false; 52 52 for(int i = 0; i < PORT_BLOCK_SIZE; i++) { 53 53 54 if(isPortAvailable(nextFreePort, silent)) {54 if(isPortAvailable(nextFreePort, verbose)) { 55 55 foundFreePort = true; 56 56 break; … … 108 108 109 109 /** @return true if the portnum is available for use */ 110 public static boolean isPortAvailable(int portnum, boolean silent) {110 public static boolean isPortAvailable(int portnum, boolean verbose) { 111 111 ServerSocket tmpSocket = null; 112 112 try { 113 113 tmpSocket = new ServerSocket(portnum); 114 114 tmpSocket.close(); 115 if( !silent) {115 if(verbose) { 116 116 System.err.println("Port " + portnum + " not yet in use."); 117 117 } … … 122 122 // socket to a local address and port. Typically, the port is 123 123 // in use, or the requested local address could not be assigned." 124 if( !silent) {124 if(verbose) { 125 125 System.err.println("Port " + portnum + " already in use or can't be assigned."); 126 126 }
Note:
See TracChangeset
for help on using the changeset viewer.