public class SocketUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LOCALHOST
Constant for localhost.
|
static int |
MAX_PORT_RANGE
The maximum port number.
|
static int |
MIN_PORT_RANGE
The minimum port number.
|
Constructor and Description |
---|
SocketUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
findAvailableTcpPort()
Finds an available TCP port.
|
static int |
findAvailableTcpPort(int minPortRange,
int maxPortRange)
Finds an available TCP port.
|
static boolean |
isTcpPortAvailable(int currentPort)
Check whether the given TCP port is available.
|
public static final java.lang.String LOCALHOST
public static final int MIN_PORT_RANGE
public static final int MAX_PORT_RANGE
public static int findAvailableTcpPort()
public static int findAvailableTcpPort(int minPortRange, int maxPortRange)
minPortRange
- The minimum port rangemaxPortRange
- The maximum port rangepublic static boolean isTcpPortAvailable(int currentPort)
currentPort
- The port