public class AvailablePortFinder extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_PORT_NUMBER
The maximum server currentMinPort number for IPv4.
|
static int |
MIN_PORT_NUMBER
The minimum server currentMinPort number for IPv4.
|
| Constructor and Description |
|---|
AvailablePortFinder(int minPortNumber)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
available(int port)
Checks to see if a specific port is available.
|
int |
getNextAvailable()
Gets the next available port starting at the lowest number.
|
int |
getNextAvailable(int fromPort)
Gets the next available port starting at a given from port.
|
public static final int MIN_PORT_NUMBER
public static final int MAX_PORT_NUMBER
public AvailablePortFinder(int minPortNumber)
public int getNextAvailable()
IllegalArgumentException - is thrown if the port number is out of rangeNoSuchElementException - if there are no ports availablepublic int getNextAvailable(int fromPort)
fromPort - the from port to scan for availabilityIllegalArgumentException - is thrown if the port number is out of rangeNoSuchElementException - if there are no ports availablepublic boolean available(int port)
throws IllegalArgumentException
port - the port number to check for availabilityIllegalArgumentException - is thrown if the port number is out of rangeCopyright © 2014-2015 Red Hat. All Rights Reserved.