- 论坛徽章:
- 1
|
我找到问题了.
在我的库中我没有调用recv 直到返回 EAGAIN. 而是认为 只是是返回原长度小于请求的长度就不再recv了..
因为我在手册中看到这么一句:
- Q9 Do I need to continuously read/write an fd until EAGAIN when using the EPOLLET flag ( Edge Triggered behaviour ) ?
- A9 No you don’t. Receiving an event from epoll_wait(2) should suggest to you that such file descriptor is ready for the requested I/O
- operation. You have simply to consider it ready until you will receive the next EAGAIN. When and how you will use such file descriptor
- is entirely up to you. Also, the condition that the read/write I/O space is exhausted can be detected by checking the amount of data
- read/write from/to the target file descriptor. For example, if you call read(2) by asking to read a certain amount of data and read(2)
- returns a lower number of bytes, you can be sure to have exhausted the read I/O space for such file descriptor. Same is valid when
- writing using the write(2) function.
复制代码
不过这样好像多调用一次recv. 按理说返回原长度小于请求的长度 就是已经表示缓冲区已空, 就已经是EWOULDBLOCK了.
这样看来还不如用水平触发方式.
[ 本帖最后由 cookis 于 2008-11-7 14:03 编辑 ] |
|