Example usage for io.netty.bootstrap AbstractBootstrap bind

List of usage examples for io.netty.bootstrap AbstractBootstrap bind

Introduction

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

Prototype

public ChannelFuture bind(SocketAddress localAddress) 

Source Link

Document

Create a new Channel and bind it.

Usage

From source file:com.streamsets.pipeline.lib.network.BaseNettyServer.java

License:Apache License

public void listen() throws Exception {
    for (SocketAddress address : addresses) {
        AbstractBootstrap b = bootstrap(enableEpoll);
        LOG.info("Starting server on address {}", address);
        if (enableEpoll) {
            // for epoll, bind for each thread
            for (int i = 0; i < numThreads; i++) {
                ChannelFuture channelFuture = b.bind(address).sync();
                channelFutures.add(channelFuture);
            }/*from  w w w  .j av a  2  s. co m*/
        } else {
            // for non-epoll (NIO threadpool), bind once
            ChannelFuture channelFuture = b.bind(address).sync();
            channelFutures.add(channelFuture);
        }
    }
}