0

有人可以帮助我了解两次启动同一个引导服务器时的网络行为。我无法捕捉到任何异常。查看我的代码:

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。

4

1 回答 1

0

我可能会误解您,但我认为您要做的是检查 bind() 操作返回的 ChannelFuture 以查看它是否成功。

bind() 是一个异步操作,因此可能无法直接完成。如果您想阻止直到它完成广告获取并自动抛出异常,请使用 bind().sync() 。

于 2013-03-13T20:49:11.053 回答