本文介绍了用于写入操作的Netty ChannelFuture何时变为“完成?”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Netty 4中,确切地说, ChannelFuture 用于写操作(假设是 NioSocketChannel )成为完成? Netty是否在等待 ACK 数据包?在将写入期货标记为已完成时, ChannelPipeline 中的输入和输出处理程序之间是否存在任何相互依赖关系?

In Netty 4, when, exactly, does the ChannelFuture for a write operation (let's say to an NioSocketChannel) become "done?" Does Netty wait for an ACK packet? Is there any interdependence between the input and output handlers in a ChannelPipeline in terms of marking write futures as done?

推荐答案

Netty不会等待 ACK 数据包。 ACK 数据包是TCP的一个实现细节,主要是(在Java中完全是?是的,但不确定C中的socket api)使用套接字隐藏到应用程序。如果你需要知道何时传递消息,你应该在你的应用层协议中添加一个确认组件。

Netty does not wait for ACK packets. ACK packets are an implementation detail of TCP that is mostly (entirely? yes in java, but not sure about socket api's in C) hidden to the application using a socket. If you need to know when messages are delivered you should add an acknowledge component to your application layer protocol.

在Netty 3.x中,Netty会调用成功方法(和在给定消息写入套接字后,在 ChannelFuture 上通知侦听器。我对Netty 4的实现细节并不熟悉,但是从我的追踪来看,我相信在Netty 4中也是如此。

In Netty 3.x, Netty would call the success method (and notify listeners) on a ChannelFuture after the given message was written to the socket. I'm not as familiar with the Netty 4 implementation details, but from my tracing though the source I believe this is also true in Netty 4.

设置未来的成功,并由。

注意写入套接字并不一定意味着已经(部分或全部)发送了消息,只是它已被写入TCP层中套接字的发送缓冲区。

Note that being written to the socket doesn't necessarily mean the message has been sent (partially or entirely), only that it has been written to the send buffer for the socket in the TCP layer.

这篇关于用于写入操作的Netty ChannelFuture何时变为“完成?”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 15:58