Netty 如何在第二次启动时处理引导启动错误
有人可以帮助我了解两次启动同一引导服务器时的棘手行为。 我看不出有什么例外。 请参阅我的代码:Netty 如何在第二次启动时处理引导启动错误,netty,bootstrapping,Netty,Bootstrapping,有人可以帮助我了解两次启动同一引导服务器时的棘手行为。 我看不出有什么例外。 请参阅我的代码: bootstrap = new ServerBootstrap(); bootstrap.group(nioEventLoopGroup); bootstrap.channel(NioServerSocketChannel.class); bootstrap.option(ChannelOption.TCP_NODELAY, Boolean.valueOf(true)); bootstrap.op
bootstrap = new ServerBootstrap();
bootstrap.group(nioEventLoopGroup);
bootstrap.channel(NioServerSocketChannel.class);
bootstrap.option(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
bootstrap.option(ChannelOption.SO_KEEPALIVE, Boolean.valueOf(true));
bootstrap.option(ChannelOption.SO_REUSEADDR, Boolean.valueOf(true));
bootstrap.childHandler(new ServerSocketBasedInitializer(messageFacade));
allChannels.add(bootstrap.bind(new InetSocketAddress(80)).channel());
我正在使用netty4.0.0.Beta2。我可能不理解您的意思,但我认为您要做的是检查bind()操作返回的ChannelFuture,看看它是否成功 bind()是一个异步操作,因此不能直接执行。如果要阻止,直到完成,ad get和异常自动抛出,请使用bind().sync()。请参阅我的答案: