public class DataConnectionProxy extends Object
Constructor and Description |
---|
DataConnectionProxy() |
Modifier and Type | Method and Description |
---|---|
static void |
setLocalPortRange(int first,
int last)
Defines the port that will be used for the server socket for all data connection proxies.
|
InetSocketAddress |
start(InetAddress bindAddress,
InetSocketAddress remoteAddress)
Finds a free port on the given local interface and creates a server socket.
|
public static void setLocalPortRange(int first, int last)
If first and last are zero (which is the default), then an "ephemeral port" is picked
for each data connection proxy (see InetSocketAddress.InetSocketAddress(int)
).
Otherwise, if first and last are equal, then exactly that port is used for the server socket of each data connection proxy (this limits the number of data connections to one at any given time).
Otherwise, first is used for the server socket of the first data connection proxy, then
first + 1
(or first - 1
, if last <
first),
and so on up to and including last, then first again, and so on. If the port is already
in use, then the next port is tried, until a "free" port is found, and a BindException
is only thrown
if all ports are already in use.
Must not be invoked after the first call to start(InetAddress, InetSocketAddress)
.
public InetSocketAddress start(InetAddress bindAddress, InetSocketAddress remoteAddress) throws IOException
bindAddress
- The local interface to bind this server toremoteAddress
- The remote address and port to connect toIOException
setLocalPortRange(int, int)
Copyright © 2018 Arno Unkrig. All rights reserved.