public class SocketUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
PORT_RANGE_MAX
The default maximum value for port ranges used when finding an available
socket port.
|
static int |
PORT_RANGE_MIN
The default minimum value for port ranges used when finding an available
socket port.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
findAvailableTcpPort()
|
static int |
findAvailableTcpPort(int minPort)
Find an available TCP port randomly selected from the range [
minPort,
65535]. |
static int |
findAvailableTcpPort(int minPort,
int maxPort)
Find an available TCP port randomly selected from the range [
minPort,
maxPort]. |
static long |
findTcpListenProcess(int port) |
static boolean |
isTcpPortAvailable(int port) |
public static final int PORT_RANGE_MIN
public static final int PORT_RANGE_MAX
public static long findTcpListenProcess(int port)
public static boolean isTcpPortAvailable(int port)
public static int findAvailableTcpPort()
IllegalStateException - if no available port could be foundpublic static int findAvailableTcpPort(int minPort)
minPort,
65535].minPort - the minimum port numberIllegalStateException - if no available port could be foundpublic static int findAvailableTcpPort(int minPort,
int maxPort)
minPort,
maxPort].minPort - the minimum port numbermaxPort - the maximum port numberIllegalStateException - if no available port could be foundCopyright © 2021. All rights reserved.