public final class SocketUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT_RANGE_MAX |
static int |
DEFAULT_PORT_RANGE_MIN |
Modifier and Type | Method and Description |
---|---|
static int |
findAvailableServerSocket()
Determines a free available server socket (port) using an automatically
chosen start seed port.
|
static int |
findAvailableServerSocket(int seed)
Determines a free available server socket (port) using the 'seed' value as
the starting port.
|
static java.util.List<java.lang.Integer> |
findAvailableServerSockets(int seed,
int numberOfRequestedPorts)
Determines a free available server socket (port) using the 'seed' value as
the starting port.
|
static int |
findAvailableUdpSocket()
Determines a free available Udp socket using an automatically
chosen start seed port.
|
static int |
findAvailableUdpSocket(int seed)
Determines a free available Udp socket (port) using the 'seed' value as
the starting port.
|
static java.util.List<java.lang.Integer> |
findAvailableUdpSockets(int seed,
int numberOfRequestedPorts)
Determines free available udp socket(s) (port) using the 'seed' value as
the starting port.
|
static int |
getRandomSeedPort()
|
public static final int DEFAULT_PORT_RANGE_MIN
public static final int DEFAULT_PORT_RANGE_MAX
public static int findAvailableServerSocket(int seed)
seed
- The starting port, which must not be negative.java.lang.IllegalStateException
- when no open port was found.public static java.util.List<java.lang.Integer> findAvailableServerSockets(int seed, int numberOfRequestedPorts)
seed
- The starting port, which must not be negative.numberOfRequestedPorts
- How many open ports shall be retrieved?java.lang.IllegalStateException
- when no open port was found.public static int findAvailableServerSocket()
java.lang.IllegalStateException
- when no open port was found.public static int findAvailableUdpSocket(int seed)
seed
- The starting port, which must not be negative.java.lang.IllegalStateException
- when no open port was found.public static java.util.List<java.lang.Integer> findAvailableUdpSockets(int seed, int numberOfRequestedPorts)
seed
- The starting port, which must not be negative.numberOfRequestedPorts
- How many open ports shall be retrieved?java.lang.IllegalStateException
- when no open port was found.public static int findAvailableUdpSocket()
java.lang.IllegalStateException
- when no open port was found.public static int getRandomSeedPort()