Example usage for io.vertx.core.net NetServerOptions setTcpKeepAlive

List of usage examples for io.vertx.core.net NetServerOptions setTcpKeepAlive

Introduction

In this page you can find the example usage for io.vertx.core.net NetServerOptions setTcpKeepAlive.

Prototype

@Override
    public NetServerOptions setTcpKeepAlive(boolean tcpKeepAlive) 

Source Link

Usage

From source file:com.sibvisions.vertx.NetSocketServer.java

License:Apache License

/**
 * Starts the server to listen on the configured port.
 *//*from w  ww  .  jav  a2  s  .  c  om*/
public void start() {
    if (vertx == null) {
        vertx = Vertx.vertx();
    }

    NetServerOptions options = new NetServerOptions();
    options.setTcpKeepAlive(true);
    options.setTcpNoDelay(true);

    srvVertx = vertx.createNetServer(options);

    srvVertx.connectHandler(new Handler<NetSocket>() {
        public void handle(NetSocket pSocket) {
            AbstractDataHandler dataHandler = new NetDataHandler(srvJVx, pSocket);

            pSocket.handler(dataHandler);
            pSocket.endHandler(new StopHandler(dataHandler));
            pSocket.exceptionHandler(new ExceptionHandler(dataHandler));
        }
    });

    srvVertx.listen(iPort, sInterface);
}