org.apache.mina.util
Class AvailablePortFinder
java.lang.Object
org.apache.mina.util.AvailablePortFinder
public class AvailablePortFinder
extends java.lang.Object
Finds currently available server ports.
static boolean | available(int port) - Checks to see if a specific port is available.
|
static Set | getAvailablePorts() - Returns the
Set of currently available port numbers
(Integer ).
|
static Set | getAvailablePorts(int fromPort, int toPort) - Returns the
Set of currently avaliable port numbers (Integer )
between the specified port range.
|
static int | getNextAvailable() - Gets the next available port starting at the lowest port number.
|
static int | getNextAvailable(int fromPort) - Gets the next available port starting at a port.
|
MAX_PORT_NUMBER
public static final int MAX_PORT_NUMBER
The maximum number of server port number.
MIN_PORT_NUMBER
public static final int MIN_PORT_NUMBER
The minimum number of server port number.
available
public static boolean available(int port)
Checks to see if a specific port is available.
port
- the port to check for availability
getAvailablePorts
public static Set getAvailablePorts()
Returns the Set
of currently available port numbers
(Integer
). This method is identical to
getAvailablePorts(MIN_PORT_NUMBER, MAX_PORT_NUMBER)
.
WARNING: this can take a very long time.
getAvailablePorts
public static Set getAvailablePorts(int fromPort,
int toPort)
Returns the Set
of currently avaliable port numbers (Integer
)
between the specified port range.
getNextAvailable
public static int getNextAvailable()
Gets the next available port starting at the lowest port number.
getNextAvailable
public static int getNextAvailable(int fromPort)
Gets the next available port starting at a port.
fromPort
- the port to scan for availability