From 10df7e29b51d6a2efacc83d870856f57d97a9b66 Mon Sep 17 00:00:00 2001 From: yanghui <2536613402@qq.com> Date: 星期一, 24 十月 2022 13:48:24 +0800 Subject: [PATCH] #feat 修改别名 --- springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java index b2f1770..21ae8f0 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_property/src/main/java/com/panzhihua/service_property/netty/NettyServer.java @@ -7,13 +7,15 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioServerSocketChannel; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; import java.net.InetSocketAddress; @Slf4j public class NettyServer { - - public void start(InetSocketAddress socketAddress) { + private static final Integer port=20012; + public void start() { //new 一个主线程组 EventLoopGroup bossGroup = new NioEventLoopGroup(1); //new 一个工作线程组 @@ -22,15 +24,14 @@ .group(bossGroup, workGroup) .channel(NioServerSocketChannel.class) .childHandler(new ServerChannelInitializer()) - .localAddress(socketAddress) //设置队列大小 .option(ChannelOption.SO_BACKLOG, 1024) // 两小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文 .childOption(ChannelOption.SO_KEEPALIVE, true); //绑定端口,开始接收进来的连接 try { - ChannelFuture future = bootstrap.bind(socketAddress).sync(); - log.info("服务器启动开始监听端口: {}", socketAddress.getPort()); + ChannelFuture future = bootstrap.bind(port).sync(); + log.info("服务器启动开始监听端口: {}", port); future.channel().closeFuture().sync(); } catch (InterruptedException e) { e.printStackTrace(); -- Gitblit v1.7.1