public class SocketUtilities extends Object
| Constructor and Description |
|---|
SocketUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getFreePort()
Return a free available port.
|
static int |
getFreePort(int minPort,
int maxPort)
Return a free available port between two ports.
|
static int |
getFreePort(int minPort,
int maxPort,
int maxTries)
Return a free available port between two ports.
|
public static int getFreePort()
public static int getFreePort(int minPort,
int maxPort)
maxPort - minPort trials will be tried. The method will return -1 if no port between min and max are available.minPort - the minimum portmaxPort - the maximum portpublic static int getFreePort(int minPort,
int maxPort,
int maxTries)
maxTries trials will be tried. The method will return -1 if no port between min and max are available.minPort - the minimum portmaxPort - the maximum portmaxTries - the maximum number of tries to get the free port