io_uring_pre...d_getsockname(3)
π io_uring_prep_cmd_getsockname β bestie edition
okay so this is a page from the liburing Manual, and it's all about io_uring_prep_cmd_getsockname(3) β yes that's the whole name, it's a long one, she's dramatic, we love her for it π
β¨ NAME β¨
io_uring_prep_cmd_getsockname β prepare a getsockname or getpeername request
πΈ SYNOPSIS πΈ
#include <sys/socket.h>
#include <liburing.h>
void io_uring_prep_cmd_getsockname(struct io_uring_sqe *sqe,
int fd,
struct sockaddr *sockaddr,
socklen_t *sockaddr_len,
int peer);
π¦ DESCRIPTION π¦
so io_uring_prep_cmd_getsockname(3) is the girl who prepares a getsockname/getpeername request. she doesn't do the whole thing herself, she just sets it up. main character energy but make it delegation π
the submission queue entry sqe gets set up to fetch the locally bound address β or the peer address β of the socket file descriptor pointed at by sockfd.
the sockaddr parameter points to a region of size sockaddr_len where the output gets written. and sockaddr_len? the kernel modifies it on return to tell you how many bytes were actually written. so yeah, she comes back changed, that's normal, that's the vibe. β¨
which address you get depends on peer, no cap:
- if
peeris set to0β you get the locally bound address - if
peeris set to1β you get the peer address
this function prepares an async getsockname(2) or getpeername(2) request. go read those man pages for the deets, they have the lore π«Ά
π RETURN VALUE π
None. that's it. nothing. she returns void and she's at peace with it π
π ERRORS π
the res field of the CQE is where the result lives. check the related man page for what values it could be, bestie.
and now the important part, listen up π₯ β where synchronous system calls would return -1 on failure and set errno to the actual error value, io_uring never uses errno. never ever. instead it returns the negated errno directly in the CQE res field. that's just how she operates.
β οΈ also, and this is the plot twist: differently from the equivalent system calls, if you try to use this operation on a non-socket file descriptor, the CQE error result isENOTSUPinstead ofENOSOCK. so like, not the error you'd expect. lowkey iconic of her to be different.
π SEE ALSO π
and that's the whole page bestie, we ate and left no crumbs πβ¨
this one's from liburing-2.13, dated December 3, 2025 β so yeah, fresh off the press, mwah π π
π¦ where this page comes from
- alpine 3.24: liburing-doc 2.14-r0 Β· LGPL-2.1-or-later OR MIT
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- nixpkgs unstable: liburing 2.14
- ubuntu resolute: liburing-dev 2.14-1
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2025 SUSE LLC
- Copyright (C) 2025 Jens Axboe <axboe@kernel.dk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms