public interface AsyncTcpSocket
Contains operations for reading and writing ByteBuf.
All read and write operations must be performed asynchronously
Implementations are supposed to use Decorator and Observer patterns which allows
to easily cascade protocol as in OSI model.
For example SSL works on top of TCP, therefore
AsyncSslSocket writes encrypted data to AsyncTcpSocketImpl, and at the same time
AsyncSslSocket is event handler
of AsyncTcpSocketImpl
| Modifier and Type | Interface and Description |
|---|---|
static interface |
AsyncTcpSocket.EventHandler
Handles events of socket
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes socket, regardless of any remaining buffered data.
|
InetSocketAddress |
getRemoteSocketAddress() |
void |
read()
Must be called to inform the async socket that additional read data is needed.
|
void |
setEventHandler(AsyncTcpSocket.EventHandler eventHandler) |
void |
write(ByteBuf buf)
Asynchronously writes data to network.
|
void |
writeEndOfStream()
Informs socket that no more data will be written.
|
void setEventHandler(AsyncTcpSocket.EventHandler eventHandler)
void read()
Unless called, the socket won't read any data from network
and therefore won't invoke AsyncTcpSocket.EventHandler.onRead(ByteBuf) callback.
Each read invocation may result in at most one
AsyncTcpSocket.EventHandler.onRead(ByteBuf) callbacks.
This operation is idempotent and may be called several times prior to actual onRead callbacks.
void write(ByteBuf buf)
When written data is flushed, AsyncTcpSocket.EventHandler.onWrite() method will be called
buf - bytes of datavoid writeEndOfStream()
AsyncTcpSocket.EventHandler.onWrite() confirmation.
This operation is idempotent.
No subsequent AsyncTcpSocket.EventHandler.onWrite() operations on the socket must be called afterwards.void close()
After calling this method no more event handler methods will be invoked
InetSocketAddress getRemoteSocketAddress()
Copyright © 2019. All rights reserved.