Search in sources :

Example 16 with DnsClient

use of io.vertx.core.dns.DnsClient in project vert.x by eclipse.

the class DNSExamples method example14.

public void example14(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.resolvePTR("1.0.0.10.in-addr.arpa", ar -> {
        if (ar.succeeded()) {
            String record = ar.result();
            System.out.println(record);
        } else {
            System.out.println("Failed to resolve entry" + ar.cause());
        }
    });
}
Also used : DnsClient(io.vertx.core.dns.DnsClient)

Example 17 with DnsClient

use of io.vertx.core.dns.DnsClient in project vert.x by eclipse.

the class DNSExamples method example10.

public void example10(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.resolveTXT("vertx.io", ar -> {
        if (ar.succeeded()) {
            List<String> records = ar.result();
            for (String record : records) {
                System.out.println(record);
            }
        } else {
            System.out.println("Failed to resolve entry" + ar.cause());
        }
    });
}
Also used : DnsClient(io.vertx.core.dns.DnsClient)

Example 18 with DnsClient

use of io.vertx.core.dns.DnsClient in project vert.x by eclipse.

the class DNSExamples method example4.

public void example4(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.lookup6("vertx.io", ar -> {
        if (ar.succeeded()) {
            System.out.println(ar.result());
        } else {
            System.out.println("Failed to resolve entry" + ar.cause());
        }
    });
}
Also used : DnsClient(io.vertx.core.dns.DnsClient)

Example 19 with DnsClient

use of io.vertx.core.dns.DnsClient in project vert.x by eclipse.

the class Examples method example16.

public void example16(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.lookup("nonexisting.vert.xio", ar -> {
        if (ar.succeeded()) {
            String record = ar.result();
            System.out.println(record);
        } else {
            Throwable cause = ar.cause();
            if (cause instanceof DnsException) {
                DnsException exception = (DnsException) cause;
                DnsResponseCode code = exception.code();
            } else {
                System.out.println("Failed to resolve entry" + ar.cause());
            }
        }
    });
}
Also used : DnsException(io.vertx.core.dns.DnsException) DnsClient(io.vertx.core.dns.DnsClient) DnsResponseCode(io.vertx.core.dns.DnsResponseCode)

Example 20 with DnsClient

use of io.vertx.core.dns.DnsClient in project vert.x by eclipse.

the class DNSExamples method example11.

public void example11(Vertx vertx) {
    DnsClient client = vertx.createDnsClient(53, "10.0.0.1");
    client.resolveNS("vertx.io", ar -> {
        if (ar.succeeded()) {
            List<String> records = ar.result();
            for (String record : records) {
                System.out.println(record);
            }
        } else {
            System.out.println("Failed to resolve entry" + ar.cause());
        }
    });
}
Also used : DnsClient(io.vertx.core.dns.DnsClient)

Aggregations

DnsClient (io.vertx.core.dns.DnsClient)30 Test (org.junit.Test)16 DnsException (io.vertx.core.dns.DnsException)4 MxRecord (io.vertx.core.dns.MxRecord)4 SrvRecord (io.vertx.core.dns.SrvRecord)4 DnsResponseCode (io.vertx.core.dns.DnsResponseCode)3 NioDatagramChannel (io.netty.channel.socket.nio.NioDatagramChannel)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 List (java.util.List)2 Bootstrap (io.netty.bootstrap.Bootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 ChannelOption (io.netty.channel.ChannelOption)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 SimpleChannelInboundHandler (io.netty.channel.SimpleChannelInboundHandler)1 DatagramChannel (io.netty.channel.socket.DatagramChannel)1 DatagramDnsQuery (io.netty.handler.codec.dns.DatagramDnsQuery)1