T - the address family encapsulated by this Connector's
associated Endpointpublic interface Connector<T>
Endpoint and
asynchronously notifies the associated ConnectionListener when the
connection completes.
A connection attempt may be terminated by a call to shutdown(),
unless the connection has already finished connecting. Once a
Connector has connected or shut down, it may not be reused.
| Modifier and Type | Method and Description |
|---|---|
void |
connect(ConnectionListener listener)
Actively initiates a connection to the associated
Endpoint. |
Endpoint<T> |
getEndpoint()
Returns the
Endpoint for this Connector. |
boolean |
isConnected()
Returns
true if this connector is connected, otherwise
returns false. |
void |
shutdown()
Shuts down this
Connector. |
boolean |
waitForConnect(long timeout)
Waits for the connect attempt, initiated by invoking the
connect method, to complete with the given timeout (specified in milliseconds), and returns true
if the connect attempt completed. |
void connect(ConnectionListener listener) throws IOException
Endpoint.
This call is non-blocking.
connected will be called
asynchronously on the given listener upon successful
connection, or disconnected
if it fails.listener - the listener for all IO events on the connection,
including the result of the connection attemptIOException - if there was a problem initiating the connectionIllegalStateException - if the Connector has been shut
down or has already attempted a connectionboolean waitForConnect(long timeout)
throws IOException,
InterruptedException
connect method, to complete with the given timeout (specified in milliseconds), and returns true
if the connect attempt completed.
Use the isConnected method on this
instance to determine if the connect attempt was successful.
timeout - the wait timeouttrue if the connect attempt completedIllegalStateException - if no connect attempt is in progressInterruptedException - if the waiting thread is interruptedIOException - if the implementation determines that the connect
attempt failed with an IOExceptionboolean isConnected()
true if this connector is connected, otherwise
returns false.true if this connector is connectedEndpoint<T> getEndpoint()
Endpoint for this Connector.Endpoint for this Connectorvoid shutdown()
Connector. The pending connection attempt
will be cancelled.IllegalStateException - if there is no connection attempt in
progressCopyright © 2007-2013. All Rights Reserved.