Home / Function/ doWriteMessage() — netty Function Reference

doWriteMessage() — netty Function Reference

Architecture documentation for the doWriteMessage() function in NioDatagramChannel.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9e078766_6a60_cbea_aef0_31352a28fa06["doWriteMessage()"]
  62bb7cb5_86a2_a73b_659d_4f8936fbd7b8["NioDatagramChannel"]
  9e078766_6a60_cbea_aef0_31352a28fa06 -->|defined in| 62bb7cb5_86a2_a73b_659d_4f8936fbd7b8
  style 9e078766_6a60_cbea_aef0_31352a28fa06 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java lines 284–312

    @Override
    protected boolean doWriteMessage(Object msg, ChannelOutboundBuffer in) throws Exception {
        final SocketAddress remoteAddress;
        final ByteBuf data;
        if (msg instanceof AddressedEnvelope) {
            @SuppressWarnings("unchecked")
            AddressedEnvelope<ByteBuf, SocketAddress> envelope = (AddressedEnvelope<ByteBuf, SocketAddress>) msg;
            remoteAddress = envelope.recipient();
            data = envelope.content();
        } else {
            data = (ByteBuf) msg;
            remoteAddress = null;
        }

        final int dataLen = data.readableBytes();
        if (dataLen == 0) {
            return true;
        }

        final ByteBuffer nioData = data.nioBufferCount() == 1 ? data.internalNioBuffer(data.readerIndex(), dataLen)
                                                              : data.nioBuffer(data.readerIndex(), dataLen);
        final int writtenBytes;
        if (remoteAddress != null) {
            writtenBytes = javaChannel().send(nioData, remoteAddress);
        } else {
            writtenBytes = javaChannel().write(nioData);
        }
        return writtenBytes > 0;
    }

Domain

Subdomains

Frequently Asked Questions

What does doWriteMessage() do?
doWriteMessage() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java.
Where is doWriteMessage() defined?
doWriteMessage() is defined in transport/src/main/java/io/netty/channel/socket/nio/NioDatagramChannel.java at line 284.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free