kernel_getsockname(9)
π kernel_getsockname(9) β the Kernel API Manual, bestie edition π
okay so you're in the kernel, you've got a struct socket *, and you need to know where it's actually bound. that's the whole vibe of this page. welcome π«Ά
β¨ SYNOPSIS β¨
int kernel_getsockname (struct socket *sock , struct sockaddr *addr );
like, look at her. two args, one int return, no notes. π
πΈ ARGUMENTS πΈ
sockβ the socket. your main character. the one we're asking about πaddrβ the address holder, i.e. the lil container that's gonna get filled up with the bound address β¨
π¦ DESCRIPTION π¦
so basically: this fills the addr pointer with the address that the socket is bound to. that's it. that's the function, no cap π
and then it returns the length of the address in bytes, or an error code if something went sideways π
bestie the return value is doing double duty here β length in bytes on the good path, error code on the bad path. pls check it, don't just ignore it π
kernel-space only, for the record π§ that's literally in the NAME section: get the address which the socket is bound (kernel space) β that's the one-line summary and yes it's iconic π
β SEE ALSO β
the whole extended friend group, in order, no gatekeeping:
Kernel file ./net/socket.cmove_addr_to_kernel(9)move_addr_to_user(9)sock_read_xattr(9)sock_alloc_file(9)sock_from_file(9)sockfd_lookup(9)sock_alloc(9)sock_release(9)sock_sendmsg(9)kernel_sendmsg(9)sock_recvmsg(9)kernel_recvmsg(9)sock_create_lite(9)__sock_create(9)sock_create(9)sock_create_kern(9)sock_register(9)sock_unregister(9)kernel_bind(9)kernel_listen(9)kernel_accept(9)kernel_connect(9)kernel_getpeername(9)kernel_sock_shutdown(9)kernel_sock_ip_overhead(9)
iykyk, this is the entire socket-girlies roster π and kernel_getpeername(9) is literally her sister function β one asks "who am I bound as", the other asks "who's on the other end" π
and that's the page!! mwah π this one comes from ./net and is dated October 2026 β so yeah, mark your calendars bestie, love you, go read kernel_getpeername(9) next π§ββοΈπ
slay π
π¦ 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