
netty教程
文章平均质量分 70
helloworldyu
好奇心呐
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
netty EventLoop write() 源码分析(二)
netty 高并发物联网交流群 651219170Netty 的write() 和 flush()下面我们就跟踪下 write() 和 flush() .验证两个事情。 1.在非 EventLoop 线程 write() 是线程安全的。 2.write() 只是把数据放到了 ChannelOutboundBuffer 中。flush() 才是把数据发送出去(在 EventLoop 线程调用的话,原创 2017-10-12 14:54:45 · 637 阅读 · 0 评论 -
netty EventLoop 源码分析(一)
Netty 核心代码分析背景都说是 netty 的 write() 在非 EventLoop 线程调用时线程安全的。但是没看过源码,总是觉得不安心。可能之前自己在写 Reactor 的时候也总是在考虑怎么解决 Reactor 线程 和普通线程 write() 怎么解决竞争问题。所以抱着学习的态度学习了下 Netty 的 EventLoop 对各种事件的处理过程(包括了我一直纠结的 write()。准原创 2017-10-12 14:39:47 · 610 阅读 · 0 评论 -
netty helloworld
一切从 helloworld 开始1.从 helloworld 开始主函数部分主函数部分,设置接收链接的 nio 池。处理事件的 nio 池。 输入任意字符退出。HelloServerpackage com.yhy;import io.netty.bootstrap.ServerBootstrap;import io.netty.channel.EventL...原创 2018-03-21 21:49:34 · 238 阅读 · 0 评论 -
netty spring 实现handler 配置
需求基础netty 中接收一个数据处理流程 inboundHandler1->inboundHandler2->inboundHandler3 netty 发送一个数据的处理流程outboundHandler3->outboundHandler2->outboundHandler1我们使用 netty 开发的时候很多初始化的代码都是重复的,一般都是 ha...原创 2018-04-03 22:31:54 · 2177 阅读 · 0 评论 -
netty 超时,登录,心跳,状态模式等解问题
物联网交流群:651219170 不要只做伸手党,希望大家能多分享多交流。在使用 netty 的时候可能会出现: 1.设备链接 netty 之后,不做登录操作,也不发送数据,白白浪费socket资源。 2.设备链接之后不做认证,就发送数据(对于这样的流氓我们肯定是断开了)。 3.设备链接之后,也登录成功了,但是网络异常,设备掉线了。这时候服务器是感知不到的(浪费资源)。 4.设备超时...原创 2018-03-29 15:48:02 · 5267 阅读 · 0 评论 -
EventLoop execute() 怎么保证线程安全
EventLoop 的 execute() 是在 SingleThreadEventLoop 中实现的。 @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task");...原创 2019-08-01 15:42:30 · 483 阅读 · 0 评论 -
EventLoop execute() 怎么保证线程安全
EventLoop 的 execute() 是在 SingleThreadEventLoop 中实现的。 @Override public void execute(Runnable task) { if (task == null) { throw new NullPointerException("task");...原创 2019-08-01 15:56:14 · 375 阅读 · 0 评论