📊 select (1983, BSD)
fd 上限: 1024(编译期硬限)
数据结构: 3 个 fd_set 位图(读 / 写 / 错)
内存占用: 永远 384 字节 (3×128B),与 fd 数无关
事件区分: 用 3 张表分开
input/output: 同一变量,会被改写(必须 master/working)
跨平台: 所有 Unix-like + Windows
性能: O(n) — 拷贝 + 遍历都是
typical 写法: 多了一份 fd_set 拷贝
📋 poll (1986, System V)
fd 上限: 无(仅受 ulimit -n)
数据结构: pollfd 结构体数组
内存占用: 8B × N(线性增长)
事件区分: events 字段位掩码
input/output: events / revents 分离,干净
跨平台: Unix-like 有 / Windows 没有
性能: O(n) — 拷贝 + 遍历都是(同 select)
typical 写法: 单数组,紧凑维护