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 InboundHandler
. E.g data from a socket
is received and needs to get processed. The InboundHandler
can convert
this to e.g. a Packet.
Channel data is written using a OutboundHandler
. 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 |
connect(InetSocketAddress address,
int timeoutMillis)
Connects the channel.
|
InboundPipeline |
inboundPipeline()
Returns the
InboundPipeline that belongs to this Channel. |
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 time epoch time in ms a read of the socket was done.
|
long |
lastWriteTimeMillis()
Returns the last time epoch time in ms a write to the socket was done.
|
SocketAddress |
localSocketAddress() |
ChannelOptions |
options()
Returns the
ChannelOptions of this Channel. |
OutboundPipeline |
outboundPipeline()
Returns the
OutboundPipeline that belongs to this Channel. |
SocketAddress |
remoteSocketAddress() |
Socket |
socket() |
void |
start()
Starts the Channel.
|
boolean |
write(OutboundFrame frame)
Queues the
OutboundFrame to be written at some point in the future. |
ChannelOptions options()
ChannelOptions
of this Channel.
Call is threadsafe; but calls to the ChannelOptions are not.ConcurrentMap attributeMap()
InboundPipeline inboundPipeline()
InboundPipeline
that belongs to this Channel.
This method is threadsafe, but most methods on the InboundPipeline
are not!OutboundPipeline outboundPipeline()
OutboundPipeline
that belongs to this Channel.
This method is threadsafe, but most methods on the OutboundPipeline
are not!Socket socket()
SocketAddress remoteSocketAddress()
SocketAddress localSocketAddress()
long lastReadTimeMillis()
long lastWriteTimeMillis()
void start()
connect(InetSocketAddress, int)
should be called before start is called.
When the Channel is started, the ChannelInitializer
will be called to
initialize the channel and to start with processing inbound and outbound data.
This method is not threadsafe and should be made only once.void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
void connect(InetSocketAddress address, int timeoutMillis) throws IOException
address
- the address to connect to.timeoutMillis
- the timeout in millis, or 0 if waiting indefinitely.IOException
- if connecting fails.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.
This method is thread-safe.frame
- the frame to write.Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.