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

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

Introduction

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

Prototype

public DatagramDnsQueryEncoder() 

Source Link

Document

Creates a new encoder with DnsRecordEncoder#DEFAULT the default record encoder .

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");
    }/*from ww  w . j a va2s.  c o m*/

    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());
        }
    });
}