Example usage for io.vertx.core.net NetSocket write

List of usage examples for io.vertx.core.net NetSocket write

Introduction

In this page you can find the example usage for io.vertx.core.net NetSocket write.

Prototype

Future<Void> write(String str);

Source Link

Document

Write a String to the connection, encoded in UTF-8.

Usage

From source file:examples.BufferExamples.java

License:Open Source License

public void example6(NetSocket socket) {
    Buffer buff = Buffer.buffer();

    buff.appendInt(123).appendString("hello\n");

    socket.write(buff);
}

From source file:examples.NetExamples.java

License:Open Source License

public void example8(NetSocket socket) {

    // Write a buffer
    Buffer buffer = Buffer.buffer().appendFloat(12.34f).appendInt(123);
    socket.write(buffer);

    // Write a string in UTF-8 encoding
    socket.write("some data");

    // Write a string using the specified encoding
    socket.write("some data", "UTF-16");

}

From source file:net.kuujo.copycat.vertx.VertxTcpProtocolServer.java

License:Apache License

/**
 * Responds to a request from the given socket.
 *///from   w  w  w.  j ava  2s . c o m
private void respond(NetSocket socket, long id, ByteBuffer response) {
    int length = response.remaining();
    byte[] bytes = new byte[length];
    response.get(bytes);
    socket.write(Buffer.buffer().appendInt(length).appendLong(id).appendBytes(bytes));
}