autoRead为false时读取了多少数据?
How much data is read when autoRead is false?
read()
的 Javadoc 说:
Request to Read data from the Channel into the first inbound buffer,
triggers an ChannelInboundHandler#channelRead event if data was read,
and triggers a ChannelInboundHandler#channelReadComplete event so the
handler can decide to continue reading.
手动调用channel.config().setAutoRead(false)
和read()
时,实际读取了多少?假设一个没有编解码器的 TCP 连接,它会读取直到入站缓冲区填满,触发 ChannelInboundHandler#channelRead
,然后停止读取吗?
查看 proxy example 它为每个 channelRead 调用 read() 一次,这似乎意味着 read()
和 channelRead 事件之间是一对一的。
socketChannel 添加了一个 class 调用
AdaptiveRecvByteBufAllocator 默认值为
static final int DEFAULT_MINIMUM = 64;
static final int DEFAULT_INITIAL = 1024;
static final int DEFAULT_MAXIMUM = 65536;
所以首先 1024 bytes
将被读取,然后它可以根据后续读取而增加或减少。您可以通过添加
来调整它
socketChannel.config().setRecvByteBufAllocator(RecvByteBufAllocator allocator)
read()
的 Javadoc 说:
Request to Read data from the Channel into the first inbound buffer, triggers an ChannelInboundHandler#channelRead event if data was read, and triggers a ChannelInboundHandler#channelReadComplete event so the handler can decide to continue reading.
手动调用channel.config().setAutoRead(false)
和read()
时,实际读取了多少?假设一个没有编解码器的 TCP 连接,它会读取直到入站缓冲区填满,触发 ChannelInboundHandler#channelRead
,然后停止读取吗?
查看 proxy example 它为每个 channelRead 调用 read() 一次,这似乎意味着 read()
和 channelRead 事件之间是一对一的。
socketChannel 添加了一个 class 调用 AdaptiveRecvByteBufAllocator 默认值为
static final int DEFAULT_MINIMUM = 64;
static final int DEFAULT_INITIAL = 1024;
static final int DEFAULT_MAXIMUM = 65536;
所以首先 1024 bytes
将被读取,然后它可以根据后续读取而增加或减少。您可以通过添加
socketChannel.config().setRecvByteBufAllocator(RecvByteBufAllocator allocator)