public class PortTracker
extends java.lang.Object
Constructor and Description |
---|
PortTracker(int minPort,
int maxPort)
Initializes a port tracker with the specified port range.
|
Modifier and Type | Method and Description |
---|---|
static PortTracker |
createTracker(java.lang.String newMinPortString,
java.lang.String newMaxPortString)
Attempts to create a port tracker that uses the min and max values
indicated by the newMinPortString and newMinPortString
strings and returns it if successful.
|
int |
getMaxPort()
Returns the highest/maximum port that this tracker would use.
|
int |
getMinPort()
Returns the lowest/minimum port that this tracker would use.
|
int |
getPort()
Returns the next port that the using class is supposed to try allocating.
|
void |
setNextPort(int nextPort)
Sets the next port to specified value unless it is outside the range that
this tracker operates in, in which case it sets it to the minimal
possible.
|
void |
setNextPort(int nextPort,
boolean validate)
Sets the next port to specified value unless allowing the caller to
request validation and force the port into the range that this tracker
operates in.
|
void |
setRange(int newMinPort,
int newMaxPort)
(Re)Sets the range that this tracker returns values in.
|
void |
tryRange(java.lang.String newMinPort,
java.lang.String newMaxPort)
Attempts to set the range specified by the min and max port string
params.
|
public PortTracker(int minPort, int maxPort)
minPort
- the minimum port that we would like to bind onmaxPort
- the maximum port that we would like to bind onpublic int getPort()
public void setRange(int newMinPort, int newMaxPort) throws java.lang.IllegalArgumentException
newMinPort
- the minimum port that we would like to bind onnewMaxPort
- the maximum port that we would like to bind onjava.lang.IllegalArgumentException
- if the arguments do not correspond to
valid port numbers, or in case newMaxPort < newMinPortpublic void tryRange(java.lang.String newMinPort, java.lang.String newMaxPort)
newMinPort
- the minimum port that we would like to bind onnewMaxPort
- the maximum port that we would like to bind onpublic void setNextPort(int nextPort, boolean validate)
nextPort
- the next port we'd like this tracker to return.validate
- determines whether this tracker should bring the new
value into its current range.public void setNextPort(int nextPort)
nextPort
- the next port we'd like this tracker to return.public int getMinPort()
public int getMaxPort()
public static PortTracker createTracker(java.lang.String newMinPortString, java.lang.String newMaxPortString)
newMinPortString
- the String
containing the minimum port
number that this tracker should allow.newMaxPortString
- the String
containing the minimum port
number that this tracker should allow.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.