public class SocketConnectorBase extends java.lang.Object implements SocketConnector
SocketConnector.| Modifier and Type | Class and Description |
|---|---|
static interface |
SocketConnectorBase.DelayStrategy
A strategy for choosing a delay after a failed connection attempt.
|
SocketConnector.ExceptionHandler| Constructor and Description |
|---|
SocketConnectorBase(java.net.InetAddress address,
int port,
int initialDelay,
int retryDelay)
Constructs a new connector.
|
SocketConnectorBase(java.net.InetAddress address,
int port,
SocketConnectorBase.DelayStrategy delayStrategy)
Constructs a new connector.
|
| Modifier and Type | Method and Description |
|---|---|
java.net.Socket |
awaitConnection() |
java.net.Socket |
awaitConnection(long delay) |
java.net.Socket |
call()
Blocks the calling thread until a connection is successfully
established.
|
void |
run() |
void |
setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
Sets the connector's exception handler.
|
void |
setSocketFactory(javax.net.SocketFactory socketFactory)
Sets the connector's socket factory.
|
public SocketConnectorBase(java.net.InetAddress address,
int port,
int initialDelay,
int retryDelay)
address - address of remote listenerport - port of remote listenerinitialDelay - delay before initial connection attemptretryDelay - delay after failed connection attemptpublic SocketConnectorBase(java.net.InetAddress address,
int port,
SocketConnectorBase.DelayStrategy delayStrategy)
address - address of remote listenerport - port of remote listenerdelayStrategy - strategy for choosing the delay to impose before
each connection attemptpublic void run()
public java.net.Socket awaitConnection()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic java.net.Socket awaitConnection(long delay)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
The handler must be set before the SocketConnector.call() method is invoked.
setExceptionHandler in interface SocketConnectorexceptionHandler - the handler to setpublic void setSocketFactory(javax.net.SocketFactory socketFactory)
If no factory is configured that connector will use the platform's default factory.
setSocketFactory in interface SocketConnectorsocketFactory - the factory to setpublic java.net.Socket call()
throws java.lang.InterruptedException
SocketConnectorcall in interface SocketConnectorcall in interface java.util.concurrent.Callable<java.net.Socket>java.lang.InterruptedException - the running connection thread was cancelled