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