Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 82497 invoked from network); 9 Nov 2004 04:35:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 9 Nov 2004 04:35:20 -0000 Received: (qmail 68555 invoked by uid 500); 9 Nov 2004 04:34:53 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 68492 invoked by uid 500); 9 Nov 2004 04:34:53 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 68459 invoked by uid 99); 9 Nov 2004 04:34:52 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 08 Nov 2004 20:34:52 -0800 Received: (qmail 82350 invoked by uid 65534); 9 Nov 2004 04:34:50 -0000 Date: 9 Nov 2004 04:34:50 -0000 Message-ID: <20041109043450.82348.qmail@minotaur.apache.org> From: akarasulu@apache.org To: directory-cvs@incubator.apache.org Subject: svn commit: rev 57000 - incubator/directory/seda/trunk/src/java/org/apache/seda/listener X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Mon Nov 8 20:34:50 2004 New Revision: 57000 Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java Log: added extra available method Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java ============================================================================== --- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java (original) +++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/AvailablePortFinder.java Mon Nov 8 20:34:50 2004 @@ -122,6 +122,44 @@ } /** + * Checks to see if a specific port is available. + * + * @param port the port to check for availability + */ + public static boolean available( int port ) + { + if ( ( port < MIN_PORT_NUMBER) || ( port > MAX_PORT_NUMBER ) ) + { + throw new IllegalArgumentException( "Invalid start port: " + port ); + } + + ServerSocket s = null; + try + { + s = new ServerSocket( port ); + return true; + } + catch ( IOException e ) + { + return false; + } + finally + { + if ( s != null ) + { + try + { + s.close(); + } + catch (IOException e) + { + /* should not be thrown */ + } + } + } + } + + /** * Returns the {@link Set} of currently avaliable port numbers ({@link Integer}) * between the specified port range. *