netty 4-3 注册一个ChannelFuture

代码如下 在Server中加入下边的代码即可

 ChannelFuture channelFuture = serverBootstrap.bind(6677).sync();
            channelFuture.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (future.isSuccess()) {
                        System.out.println("监听success");

                    } else {
                        System.out.println("监听 失败");
                    }
                }
            });

开启服务器之后的运行结果。
server is starting ------------
监听success

发布了66 篇原创文章 · 获赞 0 · 访问量 786

猜你喜欢

转载自blog.csdn.net/Be_With_I/article/details/104039411
4-3