Home / Function/ setUds() — netty Function Reference

setUds() — netty Function Reference

Architecture documentation for the setUds() function in SockaddrIn.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d173ce41_1d60_6e81_983c_35c81eb31f0a["setUds()"]
  0a4fbaf2_1e5c_bc5c_2cfb_5db23e53ba6c["SockaddrIn"]
  d173ce41_1d60_6e81_983c_35c81eb31f0a -->|defined in| 0a4fbaf2_1e5c_bc5c_2cfb_5db23e53ba6c
  style d173ce41_1d60_6e81_983c_35c81eb31f0a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport-classes-io_uring/src/main/java/io/netty/channel/uring/SockaddrIn.java lines 142–175

    static int setUds(ByteBuffer memory, DomainSocketAddress address) {
        byte[] path = address.path().getBytes(StandardCharsets.UTF_8);

        // Check if this is an abstract namespace socket (starts with '\0')
        boolean isAbstract = path.length > 0 && path[0] == 0;

        // For pathname sockets, we need space for the null terminator
        // For abstract sockets, we don't add a null terminator
        int requiredLength = isAbstract ? path.length : path.length + 1;

        if (requiredLength > Native.MAX_SUN_PATH_LEN) {
            throw new IllegalArgumentException("path too long: " + address.path());
        }

        int position = memory.position();
        memory.mark();
        try {
            memory.putShort(position + Native.SOCKADDR_UN_OFFSETOF_SUN_FAMILY, Native.AF_UNIX);
            memory.position(position + Native.SOCKADDR_UN_OFFSETOF_SUN_PATH);
            memory.put(path);

            // Only add null terminator for pathname sockets, not for abstract sockets
            if (!isAbstract) {
                memory.put((byte) 0);
            }

            // Return the actual address length:
            // - For pathname sockets: offsetof(sun_path) + strlen(path) + 1
            // - For abstract sockets: offsetof(sun_path) + name_length
            return Native.SOCKADDR_UN_OFFSETOF_SUN_PATH + requiredLength;
        } finally {
            memory.reset();
        }
    }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free