Home / Function/ main() — netty Function Reference

main() — netty Function Reference

Architecture documentation for the main() function in MsgEchoServer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a2199479_520e_5da5_174a_7ead7f6d3ac5["main()"]
  c9781103_8a22_68ef_c231_fe14475e7a3c["MsgEchoServer"]
  a2199479_520e_5da5_174a_7ead7f6d3ac5 -->|defined in| c9781103_8a22_68ef_c231_fe14475e7a3c
  style a2199479_520e_5da5_174a_7ead7f6d3ac5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/udt/echo/message/MsgEchoServer.java lines 42–72

    public static void main(String[] args) throws Exception {
        final ThreadFactory factory = new DefaultThreadFactory("udt");
        final EventLoopGroup group =
                new MultiThreadIoEventLoopGroup(
                        1, factory, NioIoHandler.newFactory(NioUdtProvider.MESSAGE_PROVIDER));

        // Configure the server.
        try {
            final ServerBootstrap boot = new ServerBootstrap();
            boot.group(group)
                    .channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR)
                    .option(ChannelOption.SO_BACKLOG, 10)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    .childHandler(new ChannelInitializer<UdtChannel>() {
                        @Override
                        public void initChannel(final UdtChannel ch)
                                throws Exception {
                            ch.pipeline().addLast(
                                    new LoggingHandler(LogLevel.INFO),
                                    new MsgEchoServerHandler());
                        }
                    });
            // Start the server.
            final ChannelFuture future = boot.bind(PORT).sync();
            // Wait until the server socket is closed.
            future.channel().closeFuture().sync();
        } finally {
            // Shut down all event loops to terminate all threads.
            group.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/udt/echo/message/MsgEchoServer.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/udt/echo/message/MsgEchoServer.java at line 42.

Analyze Your Own Codebase

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

Try Supermodel Free