|
@@ -44,21 +44,11 @@ public class SocketService {
|
|
|
// 是否关闭Nagle算法 true 高实时性,有消息立即发送 false 减少发送次数减少网络交互 提升性能(Nagle 算法)
|
|
|
.childOption(ChannelOption.TCP_NODELAY, true)
|
|
|
.childHandler(channelHandler);
|
|
|
- bind(config.getPort());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 异步监听 绑定端口是否成功 并加大端口号继续绑定
|
|
|
- *
|
|
|
- * @param port
|
|
|
- */
|
|
|
- private void bind(int port) {
|
|
|
- serverBootstrap.bind(port).addListener(future -> {
|
|
|
+ serverBootstrap.bind(config.getPort()).addListener(future -> {
|
|
|
if (future.isSuccess()) {
|
|
|
- log.info("netty port [" + port + "] bind success . ");
|
|
|
+ log.info("socket service port [" + config.getPort() + "] bind success . ");
|
|
|
} else {
|
|
|
- log.info("netty port [" + port + "] bind failure .");
|
|
|
- bind(port + 1);
|
|
|
+ log.error("socket service port [" + config.getPort() + "] bind failure .");
|
|
|
}
|
|
|
});
|
|
|
}
|