电平触发还是边沿触发?
Level-triggered or edge-triggered?
我有一个服务器应用程序,它监听一个端口,接受 (TCP) 对等连接,然后为每个套接字它
1)reads
(不超过30个字节的数据)
2) sends
(1 字节确认)
3)reads
(不超过2K)
4) sends
(1 字节确认)
5) closes
(连接)
我在我的应用程序中使用 epoll
循环。我希望 epoll_wait
到 return(带有带有 EPOLLIN 标志的事件列表)只有当所有数据都从对等方到达时,这样我才能用一个 read/recv
调用数组。如果某个套接字 fd 上没有收到所有数据,我不想 epoll
将此 fd 添加到事件列表中。
据我了解 epoll
的水平触发模式和边缘触发模式之间的差异,可以使用边缘触发 epoll
和非阻塞套接字加上有限状态来跟踪这种行为脚步。
如果边沿触发选项有误,请指正。任何的想法?
似乎无法在 epoll_wait
报告套接字准备好读取之前设置传入套接字缓冲区中可用的最小字节数。
SO_RCVLOWAT and SO_SNDLOWAT
Specify the minimum number of bytes in the buffer until the socket layer will pass the data to the protocol (SO_SNDLOWAT) or the user on receiving (SO_RCVLOWAT). These two values are initialized to 1. SO_SNDLOWAT is not changeable on Linux (setsockopt(2) fails with the error ENOPROTOOPT). SO_RCVLOWAT is changeable only since Linux 2.4. The select(2) and poll(2) system calls currently do not respect the SO_RCVLOWAT setting on Linux, and mark a socket readable when even a single byte of data is available. A subsequent read from the socket will block until SO_RCVLOWAT bytes are available.
除非手册页已过时。
我有一个服务器应用程序,它监听一个端口,接受 (TCP) 对等连接,然后为每个套接字它
1)reads
(不超过30个字节的数据)
2) sends
(1 字节确认)
3)reads
(不超过2K)
4) sends
(1 字节确认)
5) closes
(连接)
我在我的应用程序中使用 epoll
循环。我希望 epoll_wait
到 return(带有带有 EPOLLIN 标志的事件列表)只有当所有数据都从对等方到达时,这样我才能用一个 read/recv
调用数组。如果某个套接字 fd 上没有收到所有数据,我不想 epoll
将此 fd 添加到事件列表中。
据我了解 epoll
的水平触发模式和边缘触发模式之间的差异,可以使用边缘触发 epoll
和非阻塞套接字加上有限状态来跟踪这种行为脚步。
如果边沿触发选项有误,请指正。任何的想法?
似乎无法在 epoll_wait
报告套接字准备好读取之前设置传入套接字缓冲区中可用的最小字节数。
SO_RCVLOWAT and SO_SNDLOWAT
Specify the minimum number of bytes in the buffer until the socket layer will pass the data to the protocol (SO_SNDLOWAT) or the user on receiving (SO_RCVLOWAT). These two values are initialized to 1. SO_SNDLOWAT is not changeable on Linux (setsockopt(2) fails with the error ENOPROTOOPT). SO_RCVLOWAT is changeable only since Linux 2.4. The select(2) and poll(2) system calls currently do not respect the SO_RCVLOWAT setting on Linux, and mark a socket readable when even a single byte of data is available. A subsequent read from the socket will block until SO_RCVLOWAT bytes are available.
除非手册页已过时。