Home / Function/ main() — netty Function Reference

main() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  12c63114_e805_07fa_6ca1_cee0274449a9["main()"]
  11cc58bf_fa4b_4751_3ec8_db2bb32c8b2c["DiscardServer"]
  12c63114_e805_07fa_6ca1_cee0274449a9 -->|defined in| 11cc58bf_fa4b_4751_3ec8_db2bb32c8b2c
  style 12c63114_e805_07fa_6ca1_cee0274449a9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/discard/DiscardServer.java lines 39–70

    public static void main(String[] args) throws Exception {
        // Configure SSL.
        final SslContext sslCtx = ServerUtil.buildSslContext();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(group)
             .channel(NioServerSocketChannel.class)
             .handler(new LoggingHandler(LogLevel.INFO))
             .childHandler(new ChannelInitializer<SocketChannel>() {
                 @Override
                 public void initChannel(SocketChannel ch) {
                     ChannelPipeline p = ch.pipeline();
                     if (sslCtx != null) {
                         p.addLast(sslCtx.newHandler(ch.alloc()));
                     }
                     p.addLast(new DiscardServerHandler());
                 }
             });

            // Bind and start to accept incoming connections.
            ChannelFuture f = b.bind(PORT).sync();

            // Wait until the server socket is closed.
            // In this example, this does not happen, but you can do that to gracefully
            // shut down your server.
            f.channel().closeFuture().sync();
        } finally {
            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/discard/DiscardServer.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/discard/DiscardServer.java at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free