Home / Function/ clientQuery() — netty Function Reference

clientQuery() — netty Function Reference

Architecture documentation for the clientQuery() function in TcpDnsServer.java from the netty codebase.

Function java Buffer Telemetry calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  1404dde2_6698_e33d_44ec_c96c503e47f2["clientQuery()"]
  2163a46b_2065_a299_066e_84c6fa29ec99["TcpDnsServer"]
  1404dde2_6698_e33d_44ec_c96c503e47f2 -->|defined in| 2163a46b_2065_a299_066e_84c6fa29ec99
  e2c04177_18f3_85bf_661f_a4c1ab3458d3["main()"]
  e2c04177_18f3_85bf_661f_a4c1ab3458d3 -->|calls| 1404dde2_6698_e33d_44ec_c96c503e47f2
  2c8b9319_0bcc_d629_b998_8b21ecf245a6["handleQueryResp()"]
  1404dde2_6698_e33d_44ec_c96c503e47f2 -->|calls| 2c8b9319_0bcc_d629_b998_8b21ecf245a6
  style 1404dde2_6698_e33d_44ec_c96c503e47f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/dns/tcp/TcpDnsServer.java lines 114–152

    private static void clientQuery() 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) {
                            ch.pipeline().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

Called By

Frequently Asked Questions

What does clientQuery() do?
clientQuery() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/dns/tcp/TcpDnsServer.java.
Where is clientQuery() defined?
clientQuery() is defined in example/src/main/java/io/netty/example/dns/tcp/TcpDnsServer.java at line 114.
What does clientQuery() call?
clientQuery() calls 1 function(s): handleQueryResp.
What calls clientQuery()?
clientQuery() is called by 1 function(s): main.

Analyze Your Own Codebase

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

Try Supermodel Free