public interface ConnectFuture extends IoFuture
IoFuture for asynchronous connect requests.
IoConnector connector = ...; ConnectFuture future = connector.connect(...); future.awaitUninterruptibly(); // Wait until the connection attempt is finished. IoSession session = future.getSession(); session.write(...);
| Modifier and Type | Method and Description |
|---|---|
ConnectFuture |
addListener(IoFutureListener<?> listener)
Adds an event
listener which is notified when
this future is completed. |
ConnectFuture |
await()
Wait for the asynchronous operation to complete.
|
ConnectFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
boolean |
cancel()
Cancels the connection attempt and notifies all threads waiting for
this future.
|
Throwable |
getException()
Returns the cause of the connection failure.
|
IoSession |
getSession()
Returns
IoSession which is the result of connect operation. |
boolean |
isCanceled() |
boolean |
isConnected() |
ConnectFuture |
removeListener(IoFutureListener<?> listener)
Removes an existing event
listener so it won't be notified when
the future is completed. |
void |
setException(Throwable exception)
Sets the exception caught due to connection failure and notifies all
threads waiting for this future.
|
void |
setSession(IoSession session)
Sets the newly connected session and notifies all threads waiting for
this future.
|
await, await, awaitUninterruptibly, awaitUninterruptibly, isDone, join, joinIoSession getSession()
IoSession which is the result of connect operation.getSession in interface IoFuturenull otherwiseThrowable getException()
null if the connect operation is not finished yet,
or if the connection attempt is successful, otherwise returns
the cause of the exceptionboolean isConnected()
true if the connect operation is finished successfully.boolean isCanceled()
true if the connect operation has been canceled by
cancel() method.void setSession(IoSession session)
session - The created session to store in the ConnectFuture insteancevoid setException(Throwable exception)
exception - The exception to store in the ConnectFuture instanceboolean cancel()
true if the future has been cancelled by this call, false
if the future was already cancelled.ConnectFuture await() throws InterruptedException
await in interface IoFutureInterruptedException - If the thread is interrupted while waitingConnectFuture awaitUninterruptibly()
awaitUninterruptibly in interface IoFutureConnectFuture addListener(IoFutureListener<?> listener)
listener which is notified when
this future is completed. If the listener is added
after the completion, the listener is directly notified.addListener in interface IoFuturelistener - The listener to addConnectFuture removeListener(IoFutureListener<?> listener)
listener so it won't be notified when
the future is completed.removeListener in interface IoFuturelistener - The listener to removeCopyright © 2004–2024 Apache MINA Project. All rights reserved.