Home / Function/ main() — netty Function Reference

main() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b1d07fc5_2287_f232_de8e_0fb88e669738["main()"]
  4f9964c6_1d09_1770_4a27_1b2c4a01f32c["QuoteOfTheMomentClient"]
  b1d07fc5_2287_f232_de8e_0fb88e669738 -->|defined in| 4f9964c6_1d09_1770_4a27_1b2c4a01f32c
  style b1d07fc5_2287_f232_de8e_0fb88e669738 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java lines 40–66

    public static void main(String[] args) throws Exception {

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            Bootstrap b = new Bootstrap();
            b.group(group)
             .channel(NioDatagramChannel.class)
             .option(ChannelOption.SO_BROADCAST, true)
             .handler(new QuoteOfTheMomentClientHandler());

            Channel ch = b.bind(0).sync().channel();

            // Broadcast the QOTM request to port 8080.
            ch.writeAndFlush(new DatagramPacket(
                    Unpooled.copiedBuffer("QOTM?", CharsetUtil.UTF_8),
                    SocketUtils.socketAddress("255.255.255.255", PORT))).sync();

            // QuoteOfTheMomentClientHandler will close the DatagramChannel when a
            // response is received.  If the channel is not closed within 5 seconds,
            // print an error message and quit.
            if (!ch.closeFuture().await(5000)) {
                System.err.println("QOTM request timed out.");
            }
        } 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/qotm/QuoteOfTheMomentClient.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/qotm/QuoteOfTheMomentClient.java at line 40.

Analyze Your Own Codebase

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

Try Supermodel Free