|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.utils.asyncsocket.ListenableSocketChannel
public class ListenableSocketChannel
ListenableSocketChannel adds event listening convenience to the use of async sockets.
Select events (read, write, connect) are handled in thread other than selector. The thread is determined by an executor which is given as argument to the constructor. ListenableSocketChannel guarantees that each event type (read/write/connect) is handled at most by one thread.
| Nested Class Summary | |
|---|---|
static interface |
ListenableSocketChannel.ConnectionListener
|
static interface |
ListenableSocketChannel.ReadableListener
|
static interface |
ListenableSocketChannel.WriteableListener
|
| Constructor Summary | |
|---|---|
ListenableSocketChannel(Executor eventExecutor)
Create new async-socket with given event handling thread |
|
ListenableSocketChannel(SocketChannel channel,
Executor eventExecutor)
Create async-socket wrapper over given socket channel and given listener handling thread. |
|
ListenableSocketChannel(SocketChannel channel,
Executor executor,
AsyncSelector selectorThread)
Create async-socket wrapper over given socket channel, given listener handling thread, and given selector thread. |
|
| Method Summary | |
|---|---|
void |
close()
close. |
void |
connect(SocketAddress addr)
Connect to a remote socket. |
protected void |
finalize()
|
SocketChannel |
getChannel()
Getter for the field channel. |
ListenableSocketChannel.ConnectionListener |
getConnectListener()
Getter for the field connectListener. |
ListenableSocketChannel.ReadableListener |
getReadListener()
Getter for the field readListener. |
AsyncSelector |
getSelectorThread()
getSelectorThread. |
ListenableSocketChannel.WriteableListener |
getWriteListener()
Getter for the field writeListener. |
void |
setConnectListener(ListenableSocketChannel.ConnectionListener connectListener)
Set connection listener (make its selector key interested on connect events) |
void |
setReadListener(ListenableSocketChannel.ReadableListener readListener)
Set Read listener (makes its selector key interested on read events) |
void |
setWriteListener(ListenableSocketChannel.WriteableListener writeListener)
Set write listener (makes its selector key interAsyncSocketImplested on write events) |
boolean |
syncConnect(SocketAddress addr,
long timeout)
syncConnect. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ListenableSocketChannel(Executor eventExecutor)
throws IOException
eventExecutor - event handling thread or null for selector thread
IOException - if any.
public ListenableSocketChannel(SocketChannel channel,
Executor eventExecutor)
throws IOException
channel - a SocketChannel object.eventExecutor - event worker thread or null for selector thread
IOException - if any.
public ListenableSocketChannel(SocketChannel channel,
Executor executor,
AsyncSelector selectorThread)
throws IOException
channel - a SocketChannel object.executor - a Executor object.selectorThread - a AsyncSelector object.
IOException - if any.| Method Detail |
|---|
public void close()
close.
public SocketChannel getChannel()
Getter for the field channel.
SocketChannel object.public AsyncSelector getSelectorThread()
getSelectorThread.
AsyncSelector object.
public void connect(SocketAddress addr)
throws IOException
addr - a SocketAddress object.
IOException - if any.
public boolean syncConnect(SocketAddress addr,
long timeout)
throws IOException
syncConnect.
addr - a SocketAddress object.timeout - timeout in milliseconds
IOException - if any.public void setConnectListener(ListenableSocketChannel.ConnectionListener connectListener)
connectListener - a ListenableSocketChannel.ConnectionListener object.public void setReadListener(ListenableSocketChannel.ReadableListener readListener)
readListener - a ListenableSocketChannel.ReadableListener object.public void setWriteListener(ListenableSocketChannel.WriteableListener writeListener)
writeListener - a ListenableSocketChannel.WriteableListener object.public ListenableSocketChannel.ConnectionListener getConnectListener()
Getter for the field connectListener.
ListenableSocketChannel.ConnectionListener object.public ListenableSocketChannel.ReadableListener getReadListener()
Getter for the field readListener.
ListenableSocketChannel.ReadableListener object.public ListenableSocketChannel.WriteableListener getWriteListener()
Getter for the field writeListener.
ListenableSocketChannel.WriteableListener object.
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||