Small buffers for recv()

Nikolaj Thygesen mailinglist at diamondbox.dk
Tue Jun 26 16:46:00 UTC 2018


Hi,

     I'm currently writing an application which passes data between 
sub-programs through non-blocking sockets. Today I experimented (for 
testing purposes) with using buffers of different sizes for recv(). When 
I do:

     recv(fd, reinterpret_cast<char *>(buffer), size_of_buffer, 0);

... with *size_of_buffer* being e.g. 100 I get loads of EAGAIN's, but if 
I use e.g. 5000 everything works fine. I do understand why performance 
suffers, but the many EAGAIN's puzzle me a bit - what is the problem? Is 
there some way of detecting the optimal size to use? Google didn't bring 
me any closer to an answer.

     br - Nikolaj

FreeBSD fb.diamondbox.dk 11.1-RELEASE FreeBSD 11.1-RELEASE #3 r321520: 
Wed Jul 26 20:21:21 CEST 2017 user:/usr/obj/usr/src/sys/DIAMOND  amd64



More information about the freebsd-questions mailing list