public class SocketConnectorBase extends 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(InetAddress address,
int port,
int initialDelay,
int retryDelay)
Constructs a new connector.
|
SocketConnectorBase(InetAddress address,
int port,
SocketConnectorBase.DelayStrategy delayStrategy)
Constructs a new connector.
|
Modifier and Type | Method and Description |
---|---|
Socket |
awaitConnection() |
Socket |
awaitConnection(long delay) |
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(SocketFactory socketFactory)
Sets the connector's socket factory.
|
public SocketConnectorBase(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(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 Socket awaitConnection() throws InterruptedException
InterruptedException
public Socket awaitConnection(long delay) throws InterruptedException
InterruptedException
public void setExceptionHandler(SocketConnector.ExceptionHandler exceptionHandler)
The handler must be set before the SocketConnector.call()
method is invoked.
setExceptionHandler
in interface SocketConnector
exceptionHandler
- the handler to setpublic void setSocketFactory(SocketFactory socketFactory)
If no factory is configured that connector will use the platform's default factory.
setSocketFactory
in interface SocketConnector
socketFactory
- the factory to setpublic Socket call() throws InterruptedException
SocketConnector
call
in interface SocketConnector
call
in interface Callable<Socket>
InterruptedException
- the running connection thread was cancelledCopyright © 2005–2014 QOS.ch. All rights reserved.