public final class AsyncTcpSocketImpl extends Object implements AsyncTcpSocket, NioChannelEventHandler
| Modifier and Type | Class and Description |
|---|---|
static interface |
AsyncTcpSocketImpl.Inspector |
static class |
AsyncTcpSocketImpl.JmxInspector |
AsyncTcpSocket.EventHandler| Modifier and Type | Field and Description |
|---|---|
static MemSize |
DEFAULT_READ_BUF_SIZE |
static int |
NO_TIMEOUT |
static int |
OP_POSTPONED |
protected MemSize |
readMaxSize |
static AsyncTimeoutException |
TIMEOUT_EXCEPTION |
protected MemSize |
writeMaxSize |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes socket, regardless of any remaining buffered data.
|
static int |
getConnectionCount() |
InetSocketAddress |
getRemoteSocketAddress() |
SocketChannel |
getSocketChannel() |
boolean |
isOpen() |
void |
onReadReady() |
void |
onWriteReady() |
void |
read()
Must be called to inform the async socket that additional read data is needed.
|
void |
register() |
void |
setEventHandler(AsyncTcpSocket.EventHandler eventHandler) |
String |
toString() |
AsyncTcpSocketImpl |
withInspector(AsyncTcpSocketImpl.Inspector inspector) |
static AsyncTcpSocketImpl |
wrapChannel(Eventloop eventloop,
SocketChannel socketChannel) |
static AsyncTcpSocketImpl |
wrapChannel(Eventloop eventloop,
SocketChannel socketChannel,
SocketSettings socketSettings) |
void |
write(ByteBuf buf)
Asynchronously writes data to network.
|
void |
writeEndOfStream()
Informs socket that no more data will be written.
|
public static final MemSize DEFAULT_READ_BUF_SIZE
public static final int OP_POSTPONED
public static final AsyncTimeoutException TIMEOUT_EXCEPTION
public static final int NO_TIMEOUT
protected MemSize readMaxSize
protected MemSize writeMaxSize
public static AsyncTcpSocketImpl wrapChannel(Eventloop eventloop, SocketChannel socketChannel, SocketSettings socketSettings)
public static AsyncTcpSocketImpl wrapChannel(Eventloop eventloop, SocketChannel socketChannel)
public AsyncTcpSocketImpl withInspector(@Nullable AsyncTcpSocketImpl.Inspector inspector)
public void setEventHandler(AsyncTcpSocket.EventHandler eventHandler)
setEventHandler in interface AsyncTcpSocketpublic static int getConnectionCount()
public final void register()
public void read()
AsyncTcpSocket
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.
read in interface AsyncTcpSocketpublic void onReadReady()
onReadReady in interface NioChannelEventHandlerpublic void write(ByteBuf buf)
AsyncTcpSocket
When written data is flushed, AsyncTcpSocket.EventHandler.onWrite() method will be called
write in interface AsyncTcpSocketbuf - bytes of datapublic void writeEndOfStream()
AsyncTcpSocketAsyncTcpSocket.EventHandler.onWrite() confirmation.
This operation is idempotent.
No subsequent AsyncTcpSocket.EventHandler.onWrite() operations on the socket must be called afterwards.writeEndOfStream in interface AsyncTcpSocketpublic void onWriteReady()
onWriteReady in interface NioChannelEventHandlerpublic void close()
AsyncTcpSocketAfter calling this method no more event handler methods will be invoked
close in interface AsyncTcpSocketpublic boolean isOpen()
public InetSocketAddress getRemoteSocketAddress()
getRemoteSocketAddress in interface AsyncTcpSocketpublic SocketChannel getSocketChannel()
Copyright © 2019. All rights reserved.