Home / Class/ UnixChannelUtil Class — netty Architecture

UnixChannelUtil Class — netty Architecture

Architecture documentation for the UnixChannelUtil class in UnixChannelUtil.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a5a47451_0198_fe6a_e156_57cf834c5908["UnixChannelUtil"]
  9346f66b_9f44_f095_85b5_1edcc6f4e016["UnixChannelUtil.java"]
  a5a47451_0198_fe6a_e156_57cf834c5908 -->|defined in| 9346f66b_9f44_f095_85b5_1edcc6f4e016
  2aad3fc1_652d_f6d3_fde0_5f3025396bff["UnixChannelUtil()"]
  a5a47451_0198_fe6a_e156_57cf834c5908 -->|method| 2aad3fc1_652d_f6d3_fde0_5f3025396bff
  b599a0f7_31d7_bc91_9a5a_e6dc1e155175["isBufferCopyNeededForWrite()"]
  a5a47451_0198_fe6a_e156_57cf834c5908 -->|method| b599a0f7_31d7_bc91_9a5a_e6dc1e155175
  c2512991_0e8f_adff_b717_4e5737b32c63["InetSocketAddress()"]
  a5a47451_0198_fe6a_e156_57cf834c5908 -->|method| c2512991_0e8f_adff_b717_4e5737b32c63

Relationship Graph

Source Code

transport-native-unix-common/src/main/java/io/netty/channel/unix/UnixChannelUtil.java lines 26–59

public final class UnixChannelUtil {

    private UnixChannelUtil() {
    }

    /**
     * Checks if the specified buffer has memory address or is composed of n(n <= IOV_MAX) NIO direct buffers.
     * (We check this because otherwise we need to make it a new direct buffer.)
     */
    public static boolean isBufferCopyNeededForWrite(ByteBuf byteBuf) {
        return isBufferCopyNeededForWrite(byteBuf, IOV_MAX);
    }

    static boolean isBufferCopyNeededForWrite(ByteBuf byteBuf, int iovMax) {
        return !byteBuf.hasMemoryAddress() && (!byteBuf.isDirect() || byteBuf.nioBufferCount() > iovMax);
    }

    public static InetSocketAddress computeRemoteAddr(InetSocketAddress remoteAddr, InetSocketAddress osRemoteAddr) {
        if (osRemoteAddr != null) {
            try {
                // Only try to construct a new InetSocketAddress if we using java >= 7 as getHostString() does not
                // exists in earlier releases and so the retrieval of the hostname could block the EventLoop if a
                // reverse lookup would be needed.
                return new InetSocketAddress(InetAddress.getByAddress(remoteAddr.getHostString(),
                        osRemoteAddr.getAddress().getAddress()),
                        osRemoteAddr.getPort());
            } catch (UnknownHostException ignore) {
                // Should never happen but fallback to osRemoteAddr anyway.
            }
            return osRemoteAddr;
        }
        return remoteAddr;
    }
}

Frequently Asked Questions

What is the UnixChannelUtil class?
UnixChannelUtil is a class in the netty codebase, defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/UnixChannelUtil.java.
Where is UnixChannelUtil defined?
UnixChannelUtil is defined in transport-native-unix-common/src/main/java/io/netty/channel/unix/UnixChannelUtil.java at line 26.

Analyze Your Own Codebase

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

Try Supermodel Free