netty 详解
来源:互联网 发布:淘宝动态评分查询 编辑:程序博客网 时间:2024/06/06 01:13
- ServerBootstrap.bind(new InetSocketAddress(port)) 服务端绑定端口
NioEventLoopGroup bossGroup = new NioEventLoopGroup(1); – Acceptor监听客户端的线程池
NioEventLoopGroup workerGroup = new NioEventLoopGroup(2); – 处理io的线程池
1) 初始化并注册Channel
主要是根据bootstrap.channel(NioServerSocketChannel.class);来决定
ChannelFuture initAndRegister() { //1.生成Channel实例 Channel channel = NioServerSocketChannel.class.newInStance(); //2. 注册ServerBootstrapAcceptor ChannelPipeline p = channel.pipeline(); p.addLast(new ChannelInitializer<Channel>() { public void initChannel(Channel ch) throws Exception { ch.pipeline().addLast(new ServerBootstrapAcceptor( childGroup, childHandler, childOptions, childAttrs)); } }); //3. 将这个channel注册到bossGroup 里 ChannelFuture regFuture = bossGroup.register(channel); }
小注:
NioEventLoopGroup ... { private final EventExecutor[] children ; AtomicInteger childIndex = new AtomicInteger(); NioEventLoopGroup(int size) { children = new EventExecutor[size]; for (int i = 0; i < nThreads; i ++) { children[i] = new NioEventLoop(this, threadFactory...); } } public EventExecutor next() { return children[childIndex.getAndIncrement() & children.length - 1]; } public ChannelFuture register(Channel channel) { return next().register(channel); } }
http://ifeve.com/paper-set/
0 0
- Netty详解
- netty 详解
- Netty中ChannelBuffer详解
- Netty MessageDecoder decode详解
- Netty线程模型详解
- Netty框架启动详解
- Netty线程模型详解
- Netty线程模型详解
- netty 服务详解
- 【Netty基础】protobuf详解
- Netty网络编程详解
- netty原理详解
- Netty 水位详解
- netty框架中的ChannelFuture 详解
- Netty学习3-NIO详解
- Netty 4.x 实战详解
- Netty详解一(理解Netty的设计理念)
- Jboss .netty项目使用的netty包详解之 org.jboss.netty.handler.codec.base64
- HDU 2191悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
- Linux内核分析 实验四:使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
- 【Android进阶学习】shape和selector的结合使用
- 操作系统的死锁
- apt-get安装总是失败
- netty 详解
- 自定义View的总结(自定义滑动开关)
- JAVA数据结构---循环队列
- scrollview中RelativeLayout问题
- iOS9 HTTP不能正常使用的解决办法 HTTPS
- JS 数组
- Unity3d 5.0 UI穿透判断
- OpenGL es2.0 第一个例子
- 自定义ViewGroup的总结(侧滑特效)