On Linux, TCP_DEFER_ACCEPT can be enabled to defer accept calls until there is (also) data ready to be read.
On FreeBSD, SO_ACCEPTFILTER can be enabled to defer accept calls until there is a complete HTTP request (or something else) to be read.
#ifdef SO_ACCEPTFILTER accept_filter_arg afa; bzero(&afa, sizeof(afa)); strcpy(afa.af_name, "httpready"); l.setsockopt(SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); #elif TCP_DEFER_ACCEPT int v = true; setsockopt(acceptor_.native(), IPPROTO_TCP, TCP_DEFER_ACCEPT, &v, sizeof(v)); #endif
#6 Updated by stbuehler about 8 years ago
linux kernel sources (net/ipv4/tcp.c), search for TCP_DEFER_ACCEPT:
Translate value in seconds to number of retransmits
I have no idea what that means... :)
0 means disable, so i will make the option a "unsigned short" in the config, and it will be only set if it is != 0.
SO_ACCEPTFILTER is already in the source and enabled by default.
Also available in: Atom