| 協議 | RFC | 端口 | 核心邏輯 |
|---|---|---|---|
| Discard | 863 | 2009 | onMessage 只 retrieveAsString() 丟棄並記錄日誌 |
| Daytime | 867 | 2013 | onConnection 發送格式化時間字串後 shutdown() |
| Time | 868 | 2037 | onConnection 發送 4 Bytes 二進制秒數 (hostToNetwork32) 後 shutdown() |
| Echo | 862 | 2007 | onMessage retrieveAsString() 後 send() 原樣返回 |
| Chargen | 864 | 2019 | onConnection 發首包,onWriteComplete 疊加計數器並持續發送 |
解析 4 Bytes 二進制時間,處理分包情況(while readableBytes >= 4),使用 TcpClient、enableRetry()、連接斷開 loop->quit()。
直接 send(msg) 可能導致發送緩衝區堆積(Client 不讀),Chargen 通過 onWriteComplete 背壓控制發送速率。
五個 Server 共享單一 EventLoop,單線程並發處理多協議、多端口。代碼見 examples/simple/。