Package org.apache.mina.util
Class AvailablePortFinder
java.lang.Object
org.apache.mina.util.AvailablePortFinder
Finds currently available server ports.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The maximum number of server port number.static final int
The minimum number of server port number. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
available
(int port) Checks to see if a specific port is available.getAvailablePorts
(int fromPort, int toPort) static int
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.
-
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:
-
-
Method Details
-
getAvailablePorts
-
getNextAvailable
public static int getNextAvailable()Gets the next available port starting at the lowest port number.- Throws:
NoSuchElementException
- if there are no ports available
-
getNextAvailable
public static int getNextAvailable(int fromPort) Gets the next available port starting at a port.- Parameters:
fromPort
- the port to scan for availability- 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
-
getAvailablePorts
- Throws:
IllegalArgumentException
- if port range is not betweenMIN_PORT_NUMBER
andMAX_PORT_NUMBER
orfromPort
if greater thantoPort
.
-