io_uring_prep_cmd(3)
io_uring_prep_cmd(3) β bestie, it's a liburing manual page π
okay so, real talk, this one lives in the liburing manual and its whole vibe is "prep a command request for a socket". Yes, that's the NAME energy: io_uring_prep_cmd_sock β prepare a command request for a socket. Slay. Let's get into it. π«Ά
β¨ SYNOPSIS β¨
#include <liburing.h>
void io_uring_prep_cmd_sock(struct io_uring_sqe *sqe,
int cmd_op,
int fd,
int level,
int optname,
void *optval,
int optlen);
look at those args. seven of them. iconic behaviour honestly. π
π DESCRIPTION π
So io_uring_prep_cmd_sock(3) is the function that preps a cmd request for a socket, periodt. It sets up the submission queue entry sqe so that it uses the socket file descriptor that fd is pointing at, and then it kicks off a command operation defined by cmd_op. That's the whole plot. πΈ
And here's the tea: this is a generic function, so every single command out there gets to have its own individual level, optname, and optval values. Meanwhile optlen is what tells everyone how big the thing pointed to by optval actually is. π
π¦ Available commands π¦
SOCKET_URING_OP_SIOCINQ
Hands you back the amount of queued unread data chillin' in the receive buffer. But bestie β the socket must not be in LISTEN state, otherwise you get an error -EINVAL returned in the CQE res field. π
Also, for this command, level, optname, optval and optlen are not used. They're just sitting there. Third-wheeling. π
A negative return value means an error. That's it, that's the rule.
Wanna know more about this command? Go check unix(7). β¨
Available since 6.7. π₯
SOCKET_URING_OP_SIOCOUTQ
Returns the amount of unsent data sitting in the socket send queue. And same as before: the socket must not be in LISTEN state, otherwise an error -EINVAL comes back in the CQE res field. π¬
For this command too, level, optname, optval and optlen are not used.
Negative return value means an error. no cap.
More deets on this command? That's unix(7), babes. π
SOCKET_URING_OP_GETSOCKOPT
This is the command that gets options for the socket referred to by the socket file descriptor fd. The arguments are similar to the getsockopt(2) system call β like, cousins, basically. π―
Heads up though: SOCKET_URING_OP_GETSOCKOPT is limited to SOL_SOCKET level. Don't try it anywhere else.
And here's the difference from getsockopt(2): instead of doing that thing where the updated optlen value just appears, the updated optlen value is returned in the CQE res field, on success. If it fails? The CQE res contains a negative error number. π
SOCKET_URING_OP_SETSOCKOPT
This one sets options for the socket referred to by the socket file descriptor fd. And yep, the arguments are similar to the setsockopt(2) system call. π§
Available since 6.7. β
π NOTES π
The memory block pointed to byoptvalneeds to stay valid/live until theCQEreturns. Do not let it get freed early, bestie, that's how you get chaos. π
π RETURN VALUE π
Dependent on the command. (Yeah, it's giving mysterious. It's per-command, that's just the deal.) π€·
π ERRORS π
The CQE res field will contain the result of the operation. That's where you look. That's the vibe check. π
π SEE ALSO π
okay that's the whole page, you ate it, go prep some socket commands π β¨
this was brought to you by liburing-2.5, dated July 27, 2023 β and the liburing Manual, obviously. mwah. π«ΆπΈ
π¦ where this page comes from
- alpine 3.22: liburing-doc 2.9-r0 Β· LGPL-2.1-or-later OR MIT
- alpine 3.23: liburing-doc 2.12-r0 Β· LGPL-2.1-or-later OR MIT
- centos-stream 10: liburing-devel 2.12-1.el10 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- centos-stream 9: liburing-devel 2.12-1.el9 Β· (GPLv2 with exceptions and LGPLv2+) or MIT
- debian trixie: liburing-dev 2.9-1
- fedora 43: liburing-devel 2.9-2.fc43 Β· (GPL-2.0-only WITH Linux-syscall-note OR MIT) AND (LGPL-2.0-or-later OR MIT)
- fedora 43: liburing-devel 2.9-2.fc43 Β· (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)
- 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)
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- opensuse-leap 16.0: liburing-devel 2.8-160000.3.1 Β· (GPL-2.0-only AND LGPL-2.1-or-later) OR MIT
- ubuntu questing: liburing-dev 2.11-1
- π the page's license: LGPL-2.0-or-later
- Copyright (C) 2023 Breno Leitao <leitao@debian.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms