List of usage examples for io.vertx.core.datagram DatagramSocketOptions DatagramSocketOptions
public DatagramSocketOptions()
From source file:examples.DatagramExamples.java
License:Open Source License
public void example1(Vertx vertx) { DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions()); }
From source file:examples.DatagramExamples.java
License:Open Source License
public void example2(Vertx vertx) { DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions()); Buffer buffer = Buffer.buffer("content"); // Send a Buffer socket.send(buffer, 1234, "10.0.0.1", asyncResult -> { System.out.println("Send succeeded? " + asyncResult.succeeded()); });// w ww .ja va 2s.c om // Send a String socket.send("A string used as content", 1234, "10.0.0.1", asyncResult -> { System.out.println("Send succeeded? " + asyncResult.succeeded()); }); }
From source file:examples.DatagramExamples.java
License:Open Source License
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 -> { // Do something with the packet });/*from ww w .j a v a 2s . co m*/ } else { System.out.println("Listen failed" + asyncResult.cause()); } }); }
From source file:examples.DatagramExamples.java
License:Open Source License
public void example4(Vertx vertx) { DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions()); Buffer buffer = Buffer.buffer("content"); // Send a Buffer to a multicast address socket.send(buffer, 1234, "230.0.0.1", asyncResult -> { System.out.println("Send succeeded? " + asyncResult.succeeded()); });// w ww. j a v a 2s. c o m }
From source file:examples.DatagramExamples.java
License:Open Source License
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 -> { // Do something with the packet });//from w ww. j a v a 2 s . c o m // join the multicast group socket.listenMulticastGroup("230.0.0.1", asyncResult2 -> { System.out.println("Listen succeeded? " + asyncResult2.succeeded()); }); } else { System.out.println("Listen failed" + asyncResult.cause()); } }); }
From source file:examples.DatagramExamples.java
License:Open Source License
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 -> { // Do something with the packet });//from w ww .j av a 2 s .com // join the multicast group socket.listenMulticastGroup("230.0.0.1", asyncResult2 -> { if (asyncResult2.succeeded()) { // will now receive packets for group // do some work 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()); } }); }
From source file:examples.DatagramExamples.java
License:Open Source License
public void example7(Vertx vertx) { DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions()); // Some code/*from www . j av a2s . c o m*/ // 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()); }); }