public class NioChannel extends AbstractChannel
Channel
implementation tailored for non blocking IO using
Selector
in combination with a non blocking SocketChannel
.socketChannel
Constructor and Description |
---|
NioChannel(SocketChannel socketChannel,
boolean clientMode) |
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes whatever needs to be written.
|
NioChannelReader |
getReader() |
NioChannelWriter |
getWriter() |
long |
lastReadTimeMillis()
Returns the last
Clock.currentTimeMillis() a read of the socket was done. |
long |
lastWriteTimeMillis()
Returns the last
Clock.currentTimeMillis() that a write to the socket completed. |
protected void |
onClose()
Template method that is called when the socket channel closed.
|
void |
setReader(NioChannelReader reader) |
void |
setWriter(NioChannelWriter writer) |
String |
toString() |
boolean |
write(OutboundFrame frame)
Queues the
OutboundFrame to be written at some point in the future. |
addCloseListener, attributeMap, close, closeInbound, closeOutbound, getLocalSocketAddress, getRemoteSocketAddress, isClientMode, isClosed, read, socket, socketChannel, write
public NioChannel(SocketChannel socketChannel, boolean clientMode)
public void setReader(NioChannelReader reader)
public void setWriter(NioChannelWriter writer)
public NioChannelReader getReader()
public NioChannelWriter getWriter()
public boolean write(OutboundFrame frame)
Channel
OutboundFrame
to be written at some point in the future. No guarantee is made that the
frame actually is going to be written or received.frame
- the frame to write.public long lastReadTimeMillis()
Channel
Clock.currentTimeMillis()
a read of the socket was done.public long lastWriteTimeMillis()
Channel
Clock.currentTimeMillis()
that a write to the socket completed.
Writing to the socket doesn't mean that data has been send or received; it means that data was written to the
SocketChannel. It could very well be that this data is stuck somewhere in an io-buffer.public void flush()
Channel
Channel.write(OutboundFrame)
write the content; but in case of protocol
and TLS handshaking, such triggers are needed.protected void onClose()
AbstractChannel
socketChannel
is closed.
It will be called only once.
onClose
in class AbstractChannel
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.