dianxin-guizhou-forward
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 line
1.8KB

  1. package com.ssjl.zhaobiao.guizhou.netty;
  2. //
  3. //import io.netty.bootstrap.ServerBootstrap;
  4. //import io.netty.channel.ChannelFuture;
  5. //import io.netty.channel.ChannelOption;
  6. //import io.netty.channel.EventLoopGroup;
  7. //import io.netty.channel.nio.NioEventLoopGroup;
  8. //import io.netty.channel.socket.nio.NioServerSocketChannel;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.springframework.beans.factory.annotation.Value;
  11. import org.springframework.stereotype.Component;
  12. import javax.annotation.PostConstruct;
  13. import java.net.InetSocketAddress;
  14. @Slf4j
  15. @Component
  16. public class NettyServer {
  17. @Value("${netty.host}")
  18. private String host;
  19. @Value("${netty.port}")
  20. private int port;
  21. //
  22. // public void start(){
  23. // EventLoopGroup bossGroup = new NioEventLoopGroup(1);
  24. // EventLoopGroup workGroup = new NioEventLoopGroup(1);
  25. // ServerBootstrap bootstrap = new ServerBootstrap()
  26. // .group(bossGroup, workGroup)
  27. // .channel(NioServerSocketChannel.class)
  28. // .childHandler(new NettyServerInitializer())
  29. //// .localAddress(new InetSocketAddress(port))
  30. // .localAddress(host, port)
  31. // .option(ChannelOption.SO_BACKLOG, 128)
  32. // .childOption(ChannelOption.SO_KEEPALIVE, true);
  33. // try {
  34. // ChannelFuture future = bootstrap.bind().sync();
  35. //// ChannelFuture future = bootstrap.bind();
  36. // if(future.isSuccess()){
  37. // log.info("server start success");
  38. // }else{
  39. // log.info("server start error");
  40. // }
  41. //
  42. //// future.channel().closeFuture().sync();
  43. // }catch (Exception e){
  44. // e.printStackTrace();
  45. // }
  46. // finally {
  47. //// bossGroup.shutdownGracefully();
  48. //// workGroup.shutdownGracefully();
  49. // }
  50. // }
  51. }