STRUCT SOCKOPT(9)
π struct sockopt(9) β the Kernel API Manual era
okay so bestie, welcome to struct sockopt(9), straight out of the Kernel API Manual β¨ this one's a little container that holds your socket option values and honestly it's giving main character energy for something so smol π
πΈ SYNOPSIS πΈ
struct sockopt {
struct iov_iter iter_in;
struct iov_iter iter_out;
int optlen;
};
π¦ Members π¦
iter_inβ theiov_iteryou use for readingoptvalwith the content coming from the caller π usecopy_from_iter, because this iov's direction isITER_SOURCE(iykyk, direction matters, don't come for me)iter_outβ theiov_iterthat lets protocols updateoptvaldata on over to userspace π use_copy_to_iter, since this iov's direction isITER_DESTβ literally the opposite vibe ofiter_in, slayoptlenβ this one's doing double duty fr fr: it's both the input (buffer size) and the output (returned data size) π one field, two jobs, she's booked and busy
β¨ Description β¨
It's a type-safe wrapper for socket option data that works with both user and kernel buffers π«Ά no cap, that's the whole point.
And the optlen field? It lets callbacks return a specific length value that's independent of the bytes written via copy_to_iter π so you can say "bestie, the answer is this long" while writing a totally different number of bytes. iconic behaviour, honestly.
π₯ SEE ALSO π₯
- Kernel file
./include/linux/net.h enum sock_type(9)enum sock_shutdown_cmd(9)struct socket(9)
that's the whole page π§ mwah π
sign-off szn: this little gem lives in ./include/linux, its date stamp says October 2026, and it goes by struct sockopt(9) β periodt π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms