Java Code Examples for io.netty.channel.Channel.closeFuture()

The following are Jave code examples for showing how to use closeFuture() of the io.netty.channel.Channel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DovakinMQ   File: DovakinMQServer.java   Source Code and License Vote up 6 votes
public void start(){
    ServerBootstrap bootstrap = new ServerBootstrap();
    bootstrap.group(workerGroup,bossGroup)
            .channel(NioServerSocketChannel.class)
            .childHandler(new TCPHandlerInitializer(this))
            .option(ChannelOption.SO_BACKLOG, 512)
            .childOption(ChannelOption.SO_KEEPALIVE, true);
    Channel serverChannel = bootstrap.bind(new InetSocketAddress(port)).channel();
    ChannelFuture future = serverChannel.closeFuture();
    try {
        System.out.println("MQTT服务器已启动...");
        future.sync();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}