main() — netty Function Reference
Architecture documentation for the main() function in TcpDnsClient.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD cd1c434a_06e1_fddb_85cd_040fdb61f8c4["main()"] b78736d4_8edb_d42a_2963_35bd4229b033["TcpDnsClient"] cd1c434a_06e1_fddb_85cd_040fdb61f8c4 -->|defined in| b78736d4_8edb_d42a_2963_35bd4229b033 42611615_134a_300f_56c1_226f1fc075c0["handleQueryResp()"] cd1c434a_06e1_fddb_85cd_040fdb61f8c4 -->|calls| 42611615_134a_300f_56c1_226f1fc075c0 style cd1c434a_06e1_fddb_85cd_040fdb61f8c4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
example/src/main/java/io/netty/example/dns/tcp/TcpDnsClient.java lines 72–111
public static void main(String[] args) throws Exception {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
p.addLast(new TcpDnsQueryEncoder())
.addLast(new TcpDnsResponseDecoder())
.addLast(new SimpleChannelInboundHandler<DefaultDnsResponse>() {
@Override
protected void channelRead0(ChannelHandlerContext ctx, DefaultDnsResponse msg) {
try {
handleQueryResp(msg);
} finally {
ctx.close();
}
}
});
}
});
final Channel ch = b.connect(DNS_SERVER_HOST, DNS_SERVER_PORT).sync().channel();
int randomID = new Random().nextInt(60000 - 1000) + 1000;
DnsQuery query = new DefaultDnsQuery(randomID, DnsOpCode.QUERY)
.setRecord(DnsSection.QUESTION, new DefaultDnsQuestion(QUERY_DOMAIN, DnsRecordType.A));
ch.writeAndFlush(query).sync();
boolean success = ch.closeFuture().await(10, TimeUnit.SECONDS);
if (!success) {
System.err.println("dns query timeout!");
ch.close().sync();
}
} finally {
group.shutdownGracefully();
}
}
Domain
Subdomains
Calls
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/dns/tcp/TcpDnsClient.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/dns/tcp/TcpDnsClient.java at line 72.
What does main() call?
main() calls 1 function(s): handleQueryResp.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free