io_uring_pre...msg_zc_fixed(3)
β¨ io_uring_prep_sendmsg_zc_fixed β¨
okay bestie, this one's from the liburing Manual, section 3 ofc, and it's giving zero-copy sendmsg but make it fixed buffers π
π NAME π
io_uring_prep_sendmsg_zc_fixed β prep a zero-copy sendmsg using fixed buffers π¦
πΈ SYNOPSIS πΈ
#include <liburing.h>
void io_uring_prep_sendmsg_zc_fixed(struct io_uring_sqe *sqe,
int fd,
const struct msghdr *msg,
unsigned flags,
unsigned buf_index);
π DESCRIPTION π
so the io_uring_prep_sendmsg_zc_fixed(3) function preps a zero-copy sendmsg request, and it does it with fixed (registered) buffers. the submission queue entry sqe gets set up to send data on the socket that the file descriptor fd points at, using the message structure msg. literally that simple π«Ά
the flags argument holds flags for the sendmsg operation, exactly as described in sendmsg(2). no cap, go read that one if you need the deets.
the buf_index specifies the index of the registered buffer set you want to use. β οΈ the buffers inside msg must be part of the registered buffer set that you previously registered with io_uring_register_buffers(3). like, that's not optional bestie.
zero-copy sends skip copying data from user space to kernel space, which is a whole glow-up for performance on large transfers β¨π₯ and using fixed buffers on top of that also dodges the overhead of mapping buffers for every single I/O operation. ate, honestly.
π¨ okay important note: zero-copy sends require the application to wait for a notification before reusing the buffer. do NOT just send it and immediately touch that buffer again. see io_uring_prep_send_zc(3) for more details on the zero-copy semantics, iykyk π
π RETURN VALUE π
None π (it's a prep function, it doesn't return anything, it just sets up the sqe for you)
π ERRORS π
the CQE res field will contain the result of the operation β that's the number of bytes sent on success π on error, you get a negative errno value instead. sad but true.
and here's the fine print: despite accepting an array of iovec's with a size_t number of bytes each, this function can transfer at most INT_MAX bytes per call (that's the maximum for the underlying syscall interface). so like, size_t is a lie, the syscall said no π
β SEE ALSO β
io_uring_get_sqe(3)io_uring_submit(3)io_uring_prep_sendmsg_zc(3)io_uring_prep_sendmsg(3)io_uring_prep_send_zc_fixed(3)io_uring_register_buffers(3)sendmsg(2)
okay that's the whole page bestie, go send some zero-copy bytes and slay π this was liburing-2.10, dated January 18, 2025 β main character manpage energy, periodt β¨π§
π¦ where this page comes from
- arch rolling: liburing 2.15-1 Β· GPL-2.0-only WITH Linux-syscall-note OR MIT AND LGPL-2.0-or-later AND MIT
- ubuntu stonking: liburing-dev 2.15-1
- π the page's license: LGPL-2.0-or-later
- 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