main() — netty Function Reference
Architecture documentation for the main() function in SecureChatClient.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d2fc83e2_2b30_ddf5_28f9_353ddedc2a7d["main()"] a1916538_6ef5_559d_d946_3a8030dd0b48["SecureChatClient"] d2fc83e2_2b30_ddf5_28f9_353ddedc2a7d -->|defined in| a1916538_6ef5_559d_d946_3a8030dd0b48 style d2fc83e2_2b30_ddf5_28f9_353ddedc2a7d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/securechat/SecureChatClient.java lines 41–84
public static void main(String[] args) throws Exception {
// Configure SSL.
final SslContext sslCtx = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.handler(new SecureChatClientInitializer(sslCtx));
// Start the connection attempt.
Channel ch = b.connect(HOST, PORT).sync().channel();
// Read commands from the stdin.
ChannelFuture lastWriteFuture = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (;;) {
String line = in.readLine();
if (line == null) {
break;
}
// Sends the received line to the server.
lastWriteFuture = ch.writeAndFlush(line + "\r\n");
// If user typed the 'bye' command, wait until the server closes
// the connection.
if ("bye".equals(line.toLowerCase())) {
ch.closeFuture().sync();
break;
}
}
// Wait until all messages are flushed before closing the channel.
if (lastWriteFuture != null) {
lastWriteFuture.sync();
}
} finally {
// The connection is closed automatically on shutdown.
group.shutdownGracefully();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does main() do?
main() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/securechat/SecureChatClient.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/securechat/SecureChatClient.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free