场景:使用Netty UDP协议将PHP程序的运行日志推送到Elasticsearch 中 。
采用:NioDatagramChannel 通道来实现UDP数据传输
突然想到 Netty 的Reactor 线程模型 ,准备使用主从多线程Reacrtor 线程模型 。之前的代码如下
红色部分:表示在UDP协议时 使用BootStrap 而不是:ServerBootStrap
StackOverFlow 上针对 UDP 有如下的Answer
there is no need for NioServerDatagramChannel, because UDP servers open one channel for all clients.
- ServerBootstrap allows many client to connect via its channel. Therefore TCP has a dedicated ServerSocketChannel.
- Bootstrap is used to create channels for single connections. Because UDP has one channel for all clients it makes sense that only the Bootstrap is requried. All clients