Class AvailablePortFinder
java.lang.Object
org.apache.mina.util.AvailablePortFinder
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum number of server port number.static final intThe minimum number of server port number. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanavailable(int port) Checks to see if a specific port is available.getAvailablePorts(int fromPort, int toPort) static intstatic intgetNextAvailable(int fromPort)
-
Field Details
-
MIN_PORT_NUMBER
public static final int MIN_PORT_NUMBERThe minimum number of server port number.- See Also:
-
MAX_PORT_NUMBER
public static final int MAX_PORT_NUMBERThe maximum number of server port number.- See Also:
-
-
Constructor Details
-
AvailablePortFinder
private AvailablePortFinder()Creates a new instance.
-
-
Method Details
-
getAvailablePorts
-
getNextAvailable
public static int getNextAvailable()- Returns:
- an available port, selected by the system.
- Throws:
NoSuchElementException- if there are no ports available
-
getNextAvailable
public static int getNextAvailable(int fromPort) - Parameters:
fromPort- the port to scan for availability- Returns:
- the next available port starting at a port.
- Throws:
NoSuchElementException- if there are no ports available
-
available
public static boolean available(int port) Checks to see if a specific port is available.- Parameters:
port- the port to check for availability- Returns:
trueif the port is available
-
getAvailablePorts
- Parameters:
fromPort- The port we start fromtoPort- The posrt we stop at- Returns:
- the
Setof currently avalaible port numbers (Integer) between the specified port range. - Throws:
IllegalArgumentException- if port range is not betweenMIN_PORT_NUMBERandMAX_PORT_NUMBERorfromPortif greater thantoPort.
-