mariner
mariner

Reputation: 930

Netty: when does writeAndFlush channel future listener callback get executed?

I am new to netty and trying to understand how the channel future for writeAndFlush works. Consider the following code running on a netty client:

final ChannelFuture writeFuture = abacaChannel.writeAndFlush("Test");
writeFuture.addListener(new ChannelFutureListener() {
    @Override
    public void operationComplete(ChannelFuture future) throws Exception {
        if (writeFuture.isSuccess()) {
            LOGGER.debug("Write successful");
        } else {
            LOGGER.error("Error writing message to Abaca host");
        }
    }
});

When does this writeFuture operationComplete callback executed?

  1. After netty hands over the data to the OS send buffers (or)

  2. After the OS writes the data to the network socket. (or)

  3. After this data is actually received by the server.

TIA

Upvotes: 4

Views: 3978

Answers (1)

louxiu
louxiu

Reputation: 2915

1. After netty hands over the data to the OS send buffers (or)

Listener will be notified after data is removed from ChannelOutboundBuffer (netty's send buffer)

Upvotes: 5

Related Questions