Linux, C, epoll(), read() data incompleted?

前端 未结 2 1034
无人共我
无人共我 2021-01-28 15:59

Linux, C. Below issue only happens by using epoll(). If I use select() on server socket, there is no data loss.

=============================

Update: I received

相关标签:
2条回答
  • 2021-01-28 16:04
     event.events = EPOLLIN | EPOLLET;
    

    You are doing edge triggered polling. Which means your last read is probably not reading all the available data. It stops after reading 64k data, even if there is more data available. But the poll will not trigger again due to the edge trigger. Suggest removing EPOLLET.

    0 讨论(0)
  • 2021-01-28 16:11
            break;  //I do received 2 errors of Try Again. How to try again?
    

    By going back to your epoll loop.

            data: 60734  //??? why I am not able to read all 65536 bytes?
    

    Because they hadn't been received yet.

    I think you may miss the big picture on how you do non-blocking I/O with epoll.

    1. epoll tells you when there's data.
    2. You read as much as you can at that time.
    3. You go back to step 1.
    0 讨论(0)
提交回复
热议问题