public interface Channel extends Closeable
NioChannel
that uses TCP in
combination with selectors to transport data. In the future also other channel implementations could be added, e.g.
UDP based.
Channel data is read using a ChannelInboundHandler
. E.g data from a socket is received and needs to get processed.
The ChannelInboundHandler
can convert this to e.g. a Packet.
Channel data is written using a ChannelOutboundHandler
. E.g. a packet needs to be converted to bytes.
A Channel gets initialized using the ChannelInitializer
.
Modifier and Type | Method and Description |
---|---|
void |
addCloseListener(ChannelCloseListener listener)
Adds a ChannelCloseListener.
|
ConcurrentMap |
attributeMap()
Returns the attribute map.
|
void |
close()
Closes the Channel.
|
void |
closeInbound()
Closes inbound.
|
void |
closeOutbound()
Closes outbound.
|
void |
flush()
Flushes whatever needs to be written.
|
SocketAddress |
getLocalSocketAddress() |
SocketAddress |
getRemoteSocketAddress() |
boolean |
isClientMode()
Checks if this side is the Channel is in client mode or server mode.
|
boolean |
isClosed()
Checks if this Channel is closed.
|
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. |
int |
read(ByteBuffer dst)
This method will be removed from the Channel in the near future.
|
Socket |
socket() |
int |
write(ByteBuffer src)
This method will be removed from the Channel in the near future.
|
boolean |
write(OutboundFrame frame)
Queues the
OutboundFrame to be written at some point in the future. |
ConcurrentMap attributeMap()
Socket socket()
SocketAddress getRemoteSocketAddress()
SocketAddress getLocalSocketAddress()
long lastReadTimeMillis()
Clock.currentTimeMillis()
a read of the socket was done.long lastWriteTimeMillis()
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.int read(ByteBuffer dst) throws IOException
IOException
SocketChannel.read(ByteBuffer)
int write(ByteBuffer src) throws IOException
IOException
SocketChannel.write(ByteBuffer)
void closeInbound() throws IOException
Not thread safe. Should be called in channel reader thread.
Method will be removed once the TLS integration doesn't rely on subclassing this channel.IOException
void closeOutbound() throws IOException
Not thread safe. Should be called in channel writer thread.
Method will be removed once the TLS integration doesn't rely on subclassing this channel.IOException
void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
boolean isClosed()
void addCloseListener(ChannelCloseListener listener)
listener
- the listener to register.NullPointerException
- if listener is null.boolean isClientMode()
SSLEngine.getUseClientMode()
boolean write(OutboundFrame frame)
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.void flush()
write(OutboundFrame)
write the content; but in case of protocol
and TLS handshaking, such triggers are needed.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.