Home / Function/ main() — netty Function Reference

main() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  43590045_9383_788d_0c84_0fabaef95dc3["main()"]
  294451b6_d137_1cd3_e44f_aaf1870a1c03["SctpMultiHomingEchoClient"]
  43590045_9383_788d_0c84_0fabaef95dc3 -->|defined in| 294451b6_d137_1cd3_e44f_aaf1870a1c03
  style 43590045_9383_788d_0c84_0fabaef95dc3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/sctp/multihoming/SctpMultiHomingEchoClient.java lines 46–88

    public static void main(String[] args) throws Exception {
        // Configure the client.
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            Bootstrap b = new Bootstrap();
            b.group(group)
             .channel(NioSctpChannel.class)
             .option(SctpChannelOption.SCTP_NODELAY, true)
             .handler(new ChannelInitializer<SctpChannel>() {
                 @Override
                 public void initChannel(SctpChannel ch) throws Exception {
                     ch.pipeline().addLast(
//                             new LoggingHandler(LogLevel.INFO),
                             new SctpEchoClientHandler());
                 }
             });

            InetSocketAddress localAddress = SocketUtils.socketAddress(CLIENT_PRIMARY_HOST, CLIENT_PORT);
            InetAddress localSecondaryAddress = SocketUtils.addressByName(CLIENT_SECONDARY_HOST);

            InetSocketAddress remoteAddress = SocketUtils.socketAddress(SERVER_REMOTE_HOST, SERVER_REMOTE_PORT);

            // Bind the client channel.
            ChannelFuture bindFuture = b.bind(localAddress).sync();

            // Get the underlying sctp channel
            SctpChannel channel = (SctpChannel) bindFuture.channel();

            // Bind the secondary address.
            // Please note that, bindAddress in the client channel should be done before connecting if you have not
            // enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
            channel.bindAddress(localSecondaryAddress).sync();

            // Finish connect
            ChannelFuture connectFuture = channel.connect(remoteAddress).sync();

            // Wait until the connection is closed.
            connectFuture.channel().closeFuture().sync();
        } finally {
            // Shut down the event loop 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/sctp/multihoming/SctpMultiHomingEchoClient.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/sctp/multihoming/SctpMultiHomingEchoClient.java at line 46.

Analyze Your Own Codebase

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

Try Supermodel Free