Example usage for io.vertx.core.datagram DatagramSocket send

List of usage examples for io.vertx.core.datagram DatagramSocket send

Introduction

In this page you can find the example usage for io.vertx.core.datagram DatagramSocket send.

Prototype

Future<Void> send(String str, String enc, int port, String host);

Source Link

Document

Like #send(String,String,int,String,Handler) but returns a Future of the asynchronous result

Usage

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());
    });/*from  w w  w.  j a va  2  s .c  o m*/
    // 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 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());
    });/*from   w ww .j a  v  a  2  s .  c o  m*/
}