io_uring_prep_getsockname(3)
π io_uring_prep_getsockname β liburing manual, bestie edition π
okay so you're in the liburing manual, section 3, and the star of the show today is io_uring_prep_getsockname π
β¨ NAME β¨
io_uring_prep_getsockname β prepares a getsockname or getpeername request π«Ά
πΈ SYNOPSIS πΈ
#include <sys/socket.h>
#include <liburing.h>
void io_uring_prep_getsockname(struct io_uring_sqe *sqe,
int sockfd,
struct sockaddr *sockaddr,
socklen_t *sockaddr_len,
int peer);
π¦ DESCRIPTION π¦
So the way that io_uring_prep_getsockname(3) works is: it preps a getsockname/getpeername request for you, no cap. β¨
The submission queue entry sqe gets set up so it'll go fetch the locally bound address or the peer address of the socket file descriptor that sockfd is pointing at.
Now sockaddr β she points to a region of size sockaddr_len, and that's where the output gets written. π And sockaddr_len gets modified by the kernel to show how many bytes were actually written. The kernel edits your length for you, iconic behavior honestly.
Which address do you get? Depends on peer:
- if
peeris0β you get the locally bound address - if
peeris1β you get the peer address
And likeβ¦ this function is literally just preparing an async getsockname(2) or getpeername(2) request, so if you want the full tea, go read those man pages. π
π RETURN VALUE π
None. That's it. Nothing. Nada. It returns void, bestie, because all the actual results show up in the CQE. π
π₯ ERRORS π₯
The res field of the CQE is where the result of the operation lands. Peep the related man page for what values are possible. π
β οΈ Big important thing: where synchronous system calls would return-1on failure and seterrnoto the actual error value, io_uring never useserrno. Instead it returns the negated errno directly in the CQEresfield. So noerrnosnooping, periodt.
And another one that's different from the syscalls, so listen up: if the user tries to use this operation on a non-socket file descriptor, the CQE error result is -ENOTSUP instead of ENOSOCK. Yeah. Different error, different vibe. π
π SEE ALSO π
io_uring_get_sqe(3)io_uring_submit(3)io_uring_prep_getsockname(2)io_uring_prep_getpeername(2)
and that's the whole page, bestie!! π this was liburing-2.13, dated Dec 3, 2025 β go get those socket addresses, you absolute main character ππβ¨
π¦ where this page comes from
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 44: liburing-devel 2.13-2.fc44 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2024 SUSE LLC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms