Home / Class/ NioSocketChannel Class — netty Architecture

NioSocketChannel Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  f2eb70be_1f76_3e54_0854_050839fa58d4["NioSocketChannel"]
  a898000e_03c9_ff60_bd2a_29311f236921["NioSocketChannel.java"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|defined in| a898000e_03c9_ff60_bd2a_29311f236921
  921d06a6_2ded_ea38_3d3a_0932b0fde9bb["SocketChannel()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 921d06a6_2ded_ea38_3d3a_0932b0fde9bb
  f0517520_0170_a9c6_a6b1_bd046aca0f39["NioSocketChannel()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| f0517520_0170_a9c6_a6b1_bd046aca0f39
  951dd516_62a5_c0f6_ac6c_8ff96e83642a["ServerSocketChannel()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 951dd516_62a5_c0f6_ac6c_8ff96e83642a
  e8325573_7d23_bde8_97f4_7cc556c274ad["SocketChannelConfig()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| e8325573_7d23_bde8_97f4_7cc556c274ad
  017d8729_b2b3_8284_ae3a_82148de37013["isActive()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 017d8729_b2b3_8284_ae3a_82148de37013
  0c18c685_d141_0b96_6068_25ce7036b210["isOutputShutdown()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 0c18c685_d141_0b96_6068_25ce7036b210
  5bf15fe5_1f55_7d23_a827_6e2a5776a283["isInputShutdown()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 5bf15fe5_1f55_7d23_a827_6e2a5776a283
  212f999e_d2ab_7e2d_b97c_dbcdb3e7ac73["isShutdown()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 212f999e_d2ab_7e2d_b97c_dbcdb3e7ac73
  d23a0a43_8dc7_6ec1_f2b7_42dd00e5877c["InetSocketAddress()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| d23a0a43_8dc7_6ec1_f2b7_42dd00e5877c
  ef0d9cf0_98d8_e271_0ce0_6b285577ff38["doShutdownOutput()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| ef0d9cf0_98d8_e271_0ce0_6b285577ff38
  6e6cf3b0_1ae9_76f3_d17b_e1548690b2b2["ChannelFuture()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 6e6cf3b0_1ae9_76f3_d17b_e1548690b2b2
  1f424e0a_1950_35cc_726a_f9fdca8d319a["isInputShutdown0()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 1f424e0a_1950_35cc_726a_f9fdca8d319a
  33c0bd19_b36d_b43a_fce5_8c02f07775d6["shutdownOutputDone()"]
  f2eb70be_1f76_3e54_0854_050839fa58d4 -->|method| 33c0bd19_b36d_b43a_fce5_8c02f07775d6

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java lines 57–527

public class NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioSocketChannel.class);
    private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER = SelectorProvider.provider();

    private static final Method OPEN_SOCKET_CHANNEL_WITH_FAMILY =
            SelectorProviderUtil.findOpenMethod("openSocketChannel");

    private final SocketChannelConfig config;

    private static SocketChannel newChannel(SelectorProvider provider, SocketProtocolFamily family) {
        try {
            SocketChannel channel = SelectorProviderUtil.newChannel(OPEN_SOCKET_CHANNEL_WITH_FAMILY, provider, family);
            return channel == null ? provider.openSocketChannel() : channel;
        } catch (IOException e) {
            throw new ChannelException("Failed to open a socket.", e);
        }
    }

    /**
     * Create a new instance
     */
    public NioSocketChannel() {
        this(DEFAULT_SELECTOR_PROVIDER);
    }

    /**
     * Create a new instance using the given {@link SelectorProvider}.
     */
    public NioSocketChannel(SelectorProvider provider) {
        this(provider, (SocketProtocolFamily) null);
    }

    /**
     * Create a new instance using the given {@link SelectorProvider} and protocol family (supported only since JDK 15).
     *
     * @deprecated use {@link NioSocketChannel#NioSocketChannel(SelectorProvider, SocketProtocolFamily)}
     */
    @Deprecated
    public NioSocketChannel(SelectorProvider provider, InternetProtocolFamily family) {
        this(provider, family == null ? null : family.toSocketProtocolFamily());
    }

    /**
     * Create a new instance using the given {@link SelectorProvider} and protocol family (supported only since JDK 15).
     */
    public NioSocketChannel(SelectorProvider provider, SocketProtocolFamily family) {
        this(newChannel(provider, family));
    }

    /**
     * Create a new instance using the given {@link SocketChannel}.
     */
    public NioSocketChannel(SocketChannel socket) {
        this(null, socket);
    }

    /**
     * Create a new instance
     *
     * @param parent    the {@link Channel} which created this instance or {@code null} if it was created by the user
     * @param socket    the {@link SocketChannel} which will be used
     */
    public NioSocketChannel(Channel parent, SocketChannel socket) {
        super(parent, socket);
        config = new NioSocketChannelConfig(this, socket.socket());
    }

    @Override
    public ServerSocketChannel parent() {
        return (ServerSocketChannel) super.parent();
    }

    @Override
    public SocketChannelConfig config() {
        return config;
    }

    @Override
    protected SocketChannel javaChannel() {
        return (SocketChannel) super.javaChannel();
    }

Frequently Asked Questions

What is the NioSocketChannel class?
NioSocketChannel is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java.
Where is NioSocketChannel defined?
NioSocketChannel is defined in transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java at line 57.

Analyze Your Own Codebase

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

Try Supermodel Free