具有Netty 4的多端口服务器?

具有Netty 4的多端口服务器?,netty,Netty,我想在一个Netty应用程序中绑定两个服务器套接字(例如端口8000、8001) 我尝试合并服务器和EchoServer示例进行测试 但是在第一个服务器初始化代码中 ChannelFuture f = bootstrap1.bind(port).sync(); f.channel().closeFuture().sync(); // <-- program blocks here ChannelFuture f=bootstrap1.bind(port.sync(); f、 通道().c

我想在一个Netty应用程序中绑定两个服务器套接字(例如端口8000、8001)

我尝试合并服务器和EchoServer示例进行测试

但是在第一个服务器初始化代码中

ChannelFuture f = bootstrap1.bind(port).sync();
f.channel().closeFuture().sync(); // <-- program blocks here
ChannelFuture f=bootstrap1.bind(port.sync();

f、 通道().closeFuture().sync();// 只需评论一下条款

f.channel().closeFuture().sync(); // <-- program blocks here

f.channel().closeFuture().sync();// 谢谢大家!!成功了。对于其他人,我不得不补充
f、 通道().closeFuture().sync();
第二次绑定后()


添加一点,该行将等待服务器套接字关闭。但是,当我尝试在命令行中使用命令telnet localhost 8081时,我在尝试127.0.0.1时出错。。。telnet:无法连接到远程主机:连接被拒绝可能重复
    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, workerGroup)
    .channel(NioServerSocketChannel.class)
    .childHandler(new HttpServerInitializer(sslContext));
    b.bind(4443).sync();

    ServerBootstrap b1 = new ServerBootstrap();
    b1.group(bossGroupNonSSL, workerGroupNonSSL)
        .channel(NioServerSocketChannel.class)
        .childHandler(new HttpServerNonSSL());
    ChannelFuture f = b1.bind(4080).sync();

f.channel().closeFuture().sync();