Example usage for io.netty.bootstrap ServerBootstrap ServerBootstrap

List of usage examples for io.netty.bootstrap ServerBootstrap ServerBootstrap

Introduction

In this page you can find the example usage for io.netty.bootstrap ServerBootstrap ServerBootstrap.

Prototype

private ServerBootstrap(ServerBootstrap bootstrap) 

Source Link

Usage

From source file:com.spotify.netty.handler.codec.zmtp.EndToEndTest.java

License:Apache License

private Channel bind(final SocketAddress address, final ChannelHandler codec, final ChannelHandler handler) {
    final ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory());
    bootstrap.setPipeline(Channels.pipeline(codec, handler));
    return bootstrap.bind(address);
}

From source file:com.ura.proxy.HexDumpProxy.java

License:Apache License

public void start() {
    logger.info("Proxying *:" + localPort + " to " + remoteHost + ':' + remotePort + " ...");

    // Configure the bootstrap.
    Executor executor = Executors.newCachedThreadPool();
    ServerBootstrap sb = new ServerBootstrap(new NioServerSocketChannelFactory(executor, executor));

    // Set up the event pipeline factory.
    factory = new NioClientSocketChannelFactory(executor, executor);

    sb.setPipelineFactory(new HexDumpProxyPipelineFactory(factory, remoteHost, remotePort));

    // Start up the server.
    mainChannel = sb.bind(new InetSocketAddress(localPort));

}

From source file:com.ura.websocket.WebSocketServer.java

License:Apache License

public void start(int port) {

    logger.debug("Starting WS server thread");

    //ConsoleHandler ch = new ConsoleHandler();
    //ch.setLevel(Level.FINE);
    //Logger.getLogger("").addHandler(ch);
    //Logger.getLogger("").setLevel(Level.FINE);

    Executor bossExecutor = Executors.newCachedThreadPool();
    Executor workerExecutor = Executors.newCachedThreadPool();

    factory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);

    // Configure the server.
    ServerBootstrap bootstrap = new ServerBootstrap(factory);

    // Set up the event pipeline factory.
    bootstrap.setPipelineFactory(webSocketServerPipelineFactory);

    // Bind and start to accept incoming connections.
    mainChannel = bootstrap.bind(new InetSocketAddress(port));
    //ChannelFuture channelFuture = mainChannel.getCloseFuture();
    //channelFuture.awaitUninterruptibly();
    //channelFuture.getCause();
    logger.info("Finished starting port: " + port + " is now open");

}