Home / Function/ DatagramPacket() — netty Function Reference

DatagramPacket() — netty Function Reference

Architecture documentation for the DatagramPacket() function in MsgHdrMemory.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ce127401_3d43_15a0_a5be_36acd7b20e1f["DatagramPacket()"]
  99ae51db_2948_44c9_7279_d8199f61277a["MsgHdrMemory"]
  ce127401_3d43_15a0_a5be_36acd7b20e1f -->|defined in| 99ae51db_2948_44c9_7279_d8199f61277a
  style ce127401_3d43_15a0_a5be_36acd7b20e1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-io_uring/src/main/java/io/netty/channel/uring/MsgHdrMemory.java lines 146–167

    DatagramPacket get(IoUringDatagramChannel channel, IoUringIoHandler handler, ByteBuf buffer, int bytesRead) {
        InetSocketAddress sender;
        if (channel.socket.isIpv6()) {
            byte[] ipv6Bytes = handler.inet6AddressArray();
            byte[] ipv4bytes = handler.inet4AddressArray();

            sender = SockaddrIn.getIPv6(socketAddrMemory, ipv6Bytes, ipv4bytes);
        } else {
            byte[] bytes = handler.inet4AddressArray();
            sender = SockaddrIn.getIPv4(socketAddrMemory, bytes);
        }
        long bufferAddress = Iov.getBufferAddress(iovMemory);
        int bufferLength = Iov.getBufferLength(iovMemory);
        // reconstruct the reader index based on the memoryAddress of the buffer and the bufferAddress that was used
        // in the iovec.
        long memoryAddress = IoUring.memoryAddress(buffer);
        int readerIndex = (int) (bufferAddress - memoryAddress);

        ByteBuf slice = buffer.slice(readerIndex, bufferLength)
                .writerIndex(bytesRead);
        return new DatagramPacket(slice.retain(), channel.localAddress(), sender);
    }

Domain

Subdomains

Frequently Asked Questions

What does DatagramPacket() do?
DatagramPacket() is a function in the netty codebase, defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/MsgHdrMemory.java.
Where is DatagramPacket() defined?
DatagramPacket() is defined in transport-classes-io_uring/src/main/java/io/netty/channel/uring/MsgHdrMemory.java at line 146.

Analyze Your Own Codebase

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

Try Supermodel Free