What is the minimum value of SO_RCVBUF?

To minimize the delay (I don't care about packet loss), I want to get the smallest possible receive buffer for UDP. However, when I set SO_RCVBUF below 1000 (using setsockopt), my program never receives any packages. The datagrams I send have 28 bytes of data, for a total packet size in the explorer of 70 bytes, so why can't I get anything if SO_RCVBUF is <1000? And how to change this to reduce the size of the buffer?

Also, is it possible to set a buffer in terms of the number of packets, not bytes? Or can you somehow manually delete it?

+5
source share
3 answers

Reducing the number of socket buffers received will not reduce latency.

Instead, you need to remove all available packages every time. This can be done using a non-blocking socket and with a looping edge epollor kqueue- on a β€œreadable” event, until you get it EWOULDBLOCK.

As for why you are not getting any input with a small value SO_RCVBUF, see here http://vger.kernel.org/~davem/skb_sk.html , and here http://lxr.linux.no/#linux+v2 .6.37 / include / net / sock.h # L621

Hope this helps.

+4
source

Most likely it depends on the platform, so what platform are you targeting?

Windows, - - I/O, recv 0 RecvFrom().

: a) , RecvFrom(), b) .

, , , , , .

0

. . , , , . . - , , , .

0
source

All Articles