S - the type of raw channel this AbstractNioChannel usesNioChannelNioServerSocketChannel, NioSocketChannelpublic abstract class AbstractNioChannel<S extends java.nio.channels.SelectableChannel & java.nio.channels.NetworkChannel> extends java.lang.Object implements NioChannel
NioTransport.
A channel is open once it is constructed. The channel remains open and isOpen() will return
true until the channel is explicitly closed.
A channel lifecycle has two stages:
| Modifier and Type | Method | Description |
|---|---|---|
void |
addCloseListener(ActionListener<java.lang.Void> listener) |
Adds a close listener to the channel.
|
void |
close() |
Schedules a channel to be closed by the selector event loop with which it is registered.
|
void |
closeFromSelector() |
Closes the channel synchronously.
|
java.net.InetSocketAddress |
getLocalAddress() |
|
S |
getRawChannel() |
|
java.nio.channels.SelectionKey |
getSelectionKey() |
|
ESSelector |
getSelector() |
|
boolean |
isOpen() |
|
void |
register() |
This method attempts to registered a channel with the raw nio selector.
|
public boolean isOpen()
isOpen in interface NioChannelpublic java.net.InetSocketAddress getLocalAddress()
getLocalAddress in interface NioChannelpublic void close()
If the channel is open and the state can be transitioned to closed, the close operation will be scheduled with the event loop.
If the channel is already set to closed, it is assumed that it is already scheduled to be closed.
close in interface NioChannelpublic void closeFromSelector()
throws java.io.IOException
Once this method returns, the channel will be closed.
closeFromSelector in interface NioChanneljava.io.IOExceptionpublic void register()
throws java.nio.channels.ClosedChannelException
register in interface NioChanneljava.nio.channels.ClosedChannelException - if the raw channel was closedpublic ESSelector getSelector()
getSelector in interface NioChannelpublic java.nio.channels.SelectionKey getSelectionKey()
getSelectionKey in interface NioChannelpublic S getRawChannel()
getRawChannel in interface NioChannelpublic void addCloseListener(ActionListener<java.lang.Void> listener)
NioChanneladdCloseListener in interface NioChannellistener - to be called at close