private static enum SocketUtils.SocketType extends java.lang.Enum<SocketUtils.SocketType>
Modifier and Type | Method and Description |
---|---|
(package private) int |
findAvailablePort(int minPort,
int maxPort)
Find an available port for this
SocketType , randomly selected
from the range [minPort , maxPort ]. |
(package private) java.util.SortedSet<java.lang.Integer> |
findAvailablePorts(int numRequested,
int minPort,
int maxPort)
Find the requested number of available ports for this
SocketType ,
each randomly selected from the range [minPort , maxPort ]. |
private int |
findRandomPort(int minPort,
int maxPort)
Find a pseudo-random port number within the range
[
minPort , maxPort ]. |
protected abstract boolean |
isPortAvailable(int port)
Determine if the specified port for this
SocketType is
currently available on localhost . |
static SocketUtils.SocketType |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static SocketUtils.SocketType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SocketUtils.SocketType TCP
public static final SocketUtils.SocketType UDP
public static SocketUtils.SocketType[] values()
for (SocketUtils.SocketType c : SocketUtils.SocketType.values()) System.out.println(c);
public static SocketUtils.SocketType valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullprotected abstract boolean isPortAvailable(int port)
SocketType
is
currently available on localhost
.private int findRandomPort(int minPort, int maxPort)
minPort
, maxPort
].minPort
- the minimum port numbermaxPort
- the maximum port numberint findAvailablePort(int minPort, int maxPort)
SocketType
, randomly selected
from the range [minPort
, maxPort
].minPort
- the minimum port numbermaxPort
- the maximum port numberjava.lang.IllegalStateException
- if no available port could be foundjava.util.SortedSet<java.lang.Integer> findAvailablePorts(int numRequested, int minPort, int maxPort)
SocketType
,
each randomly selected from the range [minPort
, maxPort
].numRequested
- the number of available ports to findminPort
- the minimum port numbermaxPort
- the maximum port numberjava.lang.IllegalStateException
- if the requested number of available ports could not be found