Search in sources :

Example 21 with DatagramSocketOptions

use of io.vertx.core.datagram.DatagramSocketOptions in project vert.x by eclipse.

the class DatagramExamples method example3.

public void example3(Vertx vertx) {
    DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions());
    socket.listen(1234, "0.0.0.0", asyncResult -> {
        if (asyncResult.succeeded()) {
            socket.handler(packet -> {
            });
        } else {
            System.out.println("Listen failed" + asyncResult.cause());
        }
    });
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) DatagramSocket(io.vertx.core.datagram.DatagramSocket)

Example 22 with DatagramSocketOptions

use of io.vertx.core.datagram.DatagramSocketOptions in project vert.x by eclipse.

the class DatagramExamples method example6.

public void example6(Vertx vertx) {
    DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions());
    socket.listen(1234, "0.0.0.0", asyncResult -> {
        if (asyncResult.succeeded()) {
            socket.handler(packet -> {
            });
            socket.listenMulticastGroup("230.0.0.1", asyncResult2 -> {
                if (asyncResult2.succeeded()) {
                    socket.unlistenMulticastGroup("230.0.0.1", asyncResult3 -> {
                        System.out.println("Unlisten succeeded? " + asyncResult3.succeeded());
                    });
                } else {
                    System.out.println("Listen failed" + asyncResult2.cause());
                }
            });
        } else {
            System.out.println("Listen failed" + asyncResult.cause());
        }
    });
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) DatagramSocket(io.vertx.core.datagram.DatagramSocket)

Example 23 with DatagramSocketOptions

use of io.vertx.core.datagram.DatagramSocketOptions in project vert.x by eclipse.

the class DatagramExamples method example7.

public void example7(Vertx vertx) {
    DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions());
    // Some code
    // This would block packets which are send from 10.0.0.2
    socket.blockMulticastGroup("230.0.0.1", "10.0.0.2", asyncResult -> {
        System.out.println("block succeeded? " + asyncResult.succeeded());
    });
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) DatagramSocket(io.vertx.core.datagram.DatagramSocket)

Example 24 with DatagramSocketOptions

use of io.vertx.core.datagram.DatagramSocketOptions in project vert.x by eclipse.

the class DatagramExamples method example5.

public void example5(Vertx vertx) {
    DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions());
    socket.listen(1234, "0.0.0.0", asyncResult -> {
        if (asyncResult.succeeded()) {
            socket.handler(packet -> {
            });
            socket.listenMulticastGroup("230.0.0.1", asyncResult2 -> {
                System.out.println("Listen succeeded? " + asyncResult2.succeeded());
            });
        } else {
            System.out.println("Listen failed" + asyncResult.cause());
        }
    });
}
Also used : DatagramSocketOptions(io.vertx.core.datagram.DatagramSocketOptions) DatagramSocket(io.vertx.core.datagram.DatagramSocket)

Aggregations

DatagramSocketOptions (io.vertx.core.datagram.DatagramSocketOptions)24 Test (org.junit.Test)18 Buffer (io.vertx.core.buffer.Buffer)10 DatagramSocket (io.vertx.core.datagram.DatagramSocket)8 TestLoggerFactory (io.vertx.test.netty.TestLoggerFactory)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 JsonObject (io.vertx.core.json.JsonObject)2 Random (java.util.Random)2 ByteBuf (io.netty.buffer.ByteBuf)1 io.vertx.core (io.vertx.core)1 AbstractVerticle (io.vertx.core.AbstractVerticle)1 DeploymentOptions (io.vertx.core.DeploymentOptions)1 EventBus (io.vertx.core.eventbus.EventBus)1 MessageConsumer (io.vertx.core.eventbus.MessageConsumer)1 io.vertx.core.http (io.vertx.core.http)1 MetricsOptions (io.vertx.core.metrics.MetricsOptions)1 DummyVertxMetrics (io.vertx.core.metrics.impl.DummyVertxMetrics)1 io.vertx.core.net (io.vertx.core.net)1 VertxMetricsFactory (io.vertx.core.spi.VertxMetricsFactory)1 io.vertx.core.spi.metrics (io.vertx.core.spi.metrics)1