ACCF_DATA(9)
β¨ ACCF_DATA β¨
okay bestie, gather round, because today we're talking about accf_data β the accept filter that literally just makes your server wait for the vibe to arrive before it lets anybody in. π
she lives in section 9 of the kernel developer's manual, and honestly? she's giving patient queen. π
πΈ NAME πΈ
accf_data β buffer incoming connections until data arrives π
like... that's it. that's the whole job. she holds the door but doesn't open it until someone actually shows up with something to say.
π SYNOPSIS π
options INET
options ACCEPT_FILTER_DATA
kldload accf_data
three little lines, three ways to get her into your life. no cap. β¨
π¦ DESCRIPTION π¦
so here's the tea β β this is a filter, and you place it on a socket. specifically, a socket that's gonna be using accept() to receive incoming connections. that's her whole scene.
what she does: she prevents the application from receiving the connected descriptor via accept() until data actually arrives on the connection. π«Ά like, no data, no descriptor. she's not handing over the goods to a ghost. periodt.
so instead of your app waking up to a connection that's just... sitting there. silently. doing nothing. (π the worst kind of guest), she makes it wait until there's actually something to read.
also!! the ACCEPT_FILTER_DATA kernel option is also a module, which means you can enable it at runtime via kldload(8) β but only if the INET option has been compiled into the kernel. so check that first, bestie, otherwise she's not coming to the party. π
π EXAMPLES π
okay so assuming ACCEPT_FILTER_DATA has been included in the kernel config file, or the accf_data module has been loaded, this is how you enable the data accept filter on the socket sok. look at her go:
struct accept_filter_arg afa;
bzero(&afa, sizeof(afa));
strcpy(afa.af_name, "dataready");
setsockopt(sok, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa));
see that "dataready" string? that's her name at the setsockopt party. π zero the struct, copy the name, call the setsockopt, done. iconic behaviour, honestly. no notes. π
π SEE ALSO π
the whole friend group fr fr π«Ά go say hi.
β HISTORY β
the accept filter mechanism and the accf_data filter were introduced in FreeBSD 4.0. so she's been around. she's a veteran. she's got lore. πΈ
π AUTHORS π
this manual page and the filter were written by Alfred Perlstein. thank you for your service king π«‘β¨
lowkey important reminder: she only shows up if INET is compiled into your kernel. don't forget that part, bestie, or you'll be sitting there wondering why nothing works. π
and that's the whole page!! written on November 15, 2000, coming at you from Debian β yeah, this documentation is older than most of us and she's still serving. πβ¨ bye bestie, go buffer some connections π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2000 Alfred Perlstein
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms