Netty架构原理

亦凉 2022-12-20 13:59 247阅读 0赞

https://www.w3cschool.cn/essential_netty_in_action/essential_netty_in_action-x7mn28bx.html

netty server创建

  1. package com.cn.server;
  2. import io.netty.bootstrap.ServerBootstrap;
  3. import io.netty.channel.ChannelInitializer;
  4. import io.netty.channel.ChannelOption;
  5. import io.netty.channel.EventLoopGroup;
  6. import io.netty.channel.nio.NioEventLoopGroup;
  7. import io.netty.channel.socket.SocketChannel;
  8. import io.netty.channel.socket.nio.NioServerSocketChannel;
  9. import org.springframework.stereotype.Component;
  10. import com.cn.common.core.codc.RequestDecoder;
  11. import com.cn.common.core.codc.ResponseEncoder;
  12. /**
  13. * netty服务端入门
  14. *
  15. * @author -琴兽-
  16. *
  17. */
  18. @Component
  19. public class Server {
  20. /**
  21. * 启动
  22. */
  23. public void start() {
  24. // 服务类
  25. ServerBootstrap b = new ServerBootstrap();
  26. // 创建boss和worker
  27. EventLoopGroup bossGroup = new NioEventL

发表评论

表情:
评论列表 (有 0 条评论,247人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Netty通信原理

    Netty 基于Java框架NIO,进行通信 是一个异步事件驱动的,网络应用程序框架 用于快速开发可维护的高性能协议服务器和客户端 极大地简化了TCP和UDP套

    相关 Netty4详解三:Netty架构设计

            通过这一篇文章,我们基本上可以了解到Netty所有重要的组件,对Netty有一个全面的认识,这对下一步深入学习Netty是十分重要的,而学完这一章,我们其实已经