sockfd_lookup(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

okay so bestie, this is sockfd_lookup(9) from the Kernel API Manual, and it's literally the glow-up that takes you from a file number to its socket slot. iconic behavior, no cap.


✨ SYNOPSIS ✨

struct socket * sockfd_lookup (int fd , int *err );

🫢 ARGUMENTS 🫢

  • fd β€” the file handle, bestie. that's the starting point.
  • err β€” a pointer where an error code gets returned. it's giving "leave a note if things go sideways" energy.

πŸ’– DESCRIPTION πŸ’–

so here's the tea: the file handle you pass in gets locked, and the socket it's bound to is returned to you. slay.

if an error happens, the err pointer gets overwritten with a negative errno code, and you get NULL back. that's the vibe check failing, fr fr.

the function is out here checking for both invalid handles and passing a handle which is not a socket. it's not letting impostors through. πŸ’…

on success, the socket object pointer is returned. periodt. ✨


πŸ¦‹ SEE ALSO πŸ¦‹

also mentions the Kernel file ./net/socket.c, plus this whole friend group of kernel icons:


xoxo, your kernel bestie πŸ’– β€” from source/version ./net, dated October 2026 ✨

πŸ“¦ where this page comes from