min*_*avg 5 networking udp ioctl datagram
哪一个做ioctl的FIONREAD回报,下一个数据包的长度,或缓冲区中的所有数据的长度?
假设UDP服务器在客户端1的数据包之后接收来自客户端1的2个数据包和来自客户端2的另外2个数据包.那么,什么是价值ioctl的FIONREAD,又是什么readfrom在这种情况下返回?
客户端1:v两个数据包
++ UDP Server有4个包< - FIONREAD?
客户端2:^两个数据包

man udp (7)指出:
Run Code Online (Sandbox Code Playgroud)FIONREAD (SIOCINQ) Gets a pointer to an integer as argument. Returns the size of the next pending datagram in the integer in bytes, or 0 when no datagram is pending. Warning: Using FIONREAD, it is impossible to distinguish the case where no datagram is pending from the case where the next pending datagram contains zero bytes of data. It is safer to use select(2), poll(2), or epoll(7) to distinguish these cases.
因此,您的问题的答案是:FIONREAD 返回下一个(第一个)待处理数据报的大小。