Example usage for io.netty.handler.codec.dns DatagramDnsResponseDecoder DatagramDnsResponseDecoder

List of usage examples for io.netty.handler.codec.dns DatagramDnsResponseDecoder DatagramDnsResponseDecoder

Introduction

In this page you can find the example usage for io.netty.handler.codec.dns DatagramDnsResponseDecoder DatagramDnsResponseDecoder.

Prototype

public DatagramDnsResponseDecoder() 

Source Link

Document

Creates a new decoder with DnsRecordDecoder#DEFAULT the default record decoder .

Usage

From source file:io.vertx.core.dns.impl.DnsClientImpl.java

License:Open Source License

public DnsClientImpl(VertxInternal vertx, int port, String host) {

    ContextImpl creatingContext = vertx.getContext();
    if (creatingContext != null && creatingContext.isMultiThreadedWorkerContext()) {
        throw new IllegalStateException("Cannot use DnsClient in a multi-threaded worker verticle");
    }// w  w w  .j ava 2 s. c  om

    this.dnsServer = new InetSocketAddress(host, port);

    actualCtx = vertx.getOrCreateContext();
    bootstrap = new Bootstrap();
    bootstrap.group(actualCtx.nettyEventLoop());
    bootstrap.channel(NioDatagramChannel.class);
    bootstrap.option(ChannelOption.ALLOCATOR, PartialPooledByteBufAllocator.INSTANCE);
    bootstrap.handler(new ChannelInitializer<DatagramChannel>() {
        @Override
        protected void initChannel(DatagramChannel ch) throws Exception {
            ChannelPipeline pipeline = ch.pipeline();
            pipeline.addLast(new DatagramDnsQueryEncoder());
            pipeline.addLast(new DatagramDnsResponseDecoder());
        }
    });
}