Search in sources :

Example 6 with DatagramSocket

use of io.vertx.core.datagram.DatagramSocket 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 7 with DatagramSocket

use of io.vertx.core.datagram.DatagramSocket 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 8 with DatagramSocket

use of io.vertx.core.datagram.DatagramSocket 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 9 with DatagramSocket

use of io.vertx.core.datagram.DatagramSocket 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

DatagramSocket (io.vertx.core.datagram.DatagramSocket)9 DatagramSocketOptions (io.vertx.core.datagram.DatagramSocketOptions)8 Buffer (io.vertx.core.buffer.Buffer)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 io.vertx.core (io.vertx.core)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 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 Ignore (org.junit.Ignore)1