- Timestamp:
- 2009-05-13T13:55:59+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/util/PortFinder.java
r18991 r19429 47 47 * @return the number of an available port. 48 48 */ 49 public int findPortInRange( ) throws Exception {49 public int findPortInRange(boolean silent) 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 )) {54 if(isPortAvailable(nextFreePort, silent)) { 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 ) {110 public static boolean isPortAvailable(int portnum, boolean silent) { 111 111 ServerSocket tmpSocket = null; 112 112 try { 113 113 tmpSocket = new ServerSocket(portnum); 114 114 tmpSocket.close(); 115 //System.err.println("Port " + portnum + " not yet in use."); 115 if(!silent) { 116 System.err.println("Port " + portnum + " not yet in use."); 117 } 116 118 return true; 117 119 … … 120 122 // socket to a local address and port. Typically, the port is 121 123 // in use, or the requested local address could not be assigned." 122 System.err.println("Port " + portnum + " already in use or can't be assigned."); 124 if(!silent) { 125 System.err.println("Port " + portnum + " already in use or can't be assigned."); 126 } 123 127 tmpSocket = null; 124 128 return false;
Note:
See TracChangeset
for help on using the changeset viewer.