|
|
@@ -158,12 +158,12 @@ public class DipperPositionServer { |
|
|
|
EventLoopGroup mainThreadGroup = new NioEventLoopGroup(1); |
|
|
|
//new 一个工作线程组 |
|
|
|
EventLoopGroup workThreadGroup = new NioEventLoopGroup(200); |
|
|
|
//InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,null); |
|
|
|
InetSocketAddress socketAddress = new InetSocketAddress(serverAddr,9011); |
|
|
|
ServerBootstrap bootstrap = new ServerBootstrap() |
|
|
|
.group(mainThreadGroup, workThreadGroup) |
|
|
|
.channel(NioServerSocketChannel.class) |
|
|
|
.childHandler(new ServerChannelInitializer()) |
|
|
|
//.localAddress(socketAddress) |
|
|
|
.localAddress(socketAddress) |
|
|
|
//设置队列大小 |
|
|
|
.option(ChannelOption.SO_BACKLOG, 1024) |
|
|
|
// 两小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文 |
|
|
@@ -181,6 +181,7 @@ public class DipperPositionServer { |
|
|
|
System.out.println("start failed"); |
|
|
|
} |
|
|
|
}); |
|
|
|
channelFuture.channel().closeFuture().sync(); |
|
|
|
|
|
|
|
ChannelFuture channelFuture2 = bootstrap.bind(posAsycPort).sync(); |
|
|
|
log.info("位置服务器启动开始监听端口: {}", posAsycPort); |
|
|
@@ -191,6 +192,7 @@ public class DipperPositionServer { |
|
|
|
System.out.println("start failed"); |
|
|
|
} |
|
|
|
}); |
|
|
|
channelFuture2.channel().closeFuture().sync(); |
|
|
|
|
|
|
|
|
|
|
|
ChannelFuture channelFuture3 = bootstrap.bind(starsAsycPort).sync(); |
|
|
@@ -202,8 +204,7 @@ public class DipperPositionServer { |
|
|
|
System.out.println("start failed"); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//channelFuture.channel().closeFuture().sync(); |
|
|
|
channelFuture3.channel().closeFuture().sync(); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} finally { |
|
|
|