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

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

Introduction

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

Prototype

Future<Void> close();

Source Link

Document

Close the NetSocket

Usage

From source file:com.groupon.vertx.memcache.stream.MemcacheSocket.java

License:Apache License

public MemcacheSocket(final NetSocket socket, ConcurrentLinkedQueue<MemcacheCommand> pendingCommands) {
    this.socket = socket;
    this.output = new MemcacheOutputStream(socket);
    this.pendingCommands = pendingCommands;
    this.input = new MemcacheInputStream(pendingCommands);

    socket.handler(buffer -> {//from w w  w.  j  av a2s.c om
        try {
            input.processBuffer(buffer);
        } catch (Exception ex) {
            // Error processing the commands so close the socket.
            socket.close();
        }
    });
}

From source file:com.groupon.vertx.redis.RedisSocket.java

License:Apache License

public RedisSocket(final NetSocket socket) {
    this.socket = socket;
    this.output = new RedisOutputStream(socket);
    this.pendingCommands = new ConcurrentLinkedQueue<>();
    this.input = new RedisInputStream(pendingCommands);

    socket.handler(new Handler<Buffer>() {
        public void handle(Buffer buff) {
            try {
                log.trace("handle", "beforeProcessBuffer");
                input.processBuffer(buff);
            } catch (Exception ex) {
                log.error("handle", "exception", "unknown", ex);
                // Error processing the commands so close the socket.
                socket.close();
            }/*  w  w w .  ja v a2  s.  c o  m*/
        }
    });
}

From source file:io.reactiverse.pgclient.ProxyServer.java

License:Apache License

private void handle(NetSocket clientSocket) {
    clientSocket.pause();/*from   ww  w.  j  a v  a2s  . c  om*/
    client.connect(pgPort, pgHost, ar -> {
        if (ar.succeeded()) {
            NetSocket serverSocket = ar.result();
            serverSocket.pause();
            Connection conn = new Connection(clientSocket, serverSocket);
            proxyHandler.handle(conn);
        } else {
            clientSocket.close();
        }
    });
}