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
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.
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.
ChannelOutboundBuffer.remove() @ ChannelOutboundBuffer.java:263 sets the success of the future and is called by NioSocketChannel.doWrite(ChannelOutboundBuffer) @ NioSocketChannel.java:264 after a message is done being written to the socket.
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.