public static int getNextAvailable ( int fromPort ) { if ( fromPort < MIN_PORT_NUMBER || fromPort > MAX_PORT_NUMBER ) { throw new IllegalArgumentException ( "Invalid start port: " + fromPort ) ; } for ( int i = fromPort ; i <= MAX_PORT_NUMBER ; i ++ ) { if ( available ( i ) ) { return i ; } } throw new NoSuchElementException ( "Could not find an available port " + "above " + fromPort ) ; }
Gets the next available port starting at a port .