UDP Server Socket Buffer Overflow

前端 未结 3 1776
南旧
南旧 2021-02-09 17:20

I am writing a C++ application on Linux. My application has a UDP server which sends data to clients on some events. The UDP server also receives some feedback/acknowledgement

3条回答
  •  长情又很酷
    2021-02-09 17:44

    Having socket reading at fixed interval of four seconds definitely sets you up for losing packets. The conventional tried-and-true approach to non-blocking I/O is the de-multiplexer system calls select(2)/poll(2)/epoll(7). See if you can use these to capture/react to your other events.

    On the other hand, since you are already using threads, you can just do blocking recv(2) without that four second sleep.

    Read Stevens for explanation of SO_RCVBUF.

提交回复
热议问题