NNG_AIO(5)
π NNG_AIO π
okay bestie, welcome to the nng_aio page β that's the asynchronous I/O handle from the NNG Reference Manual, and yes it's giving main character energy β¨
β¨ SYNOPSIS β¨
#include <nng/nng.h>
typedef struct nng_aio nng_aio;
π¦ DESCRIPTION π¦
so. an nng_aio is an opaque structure β meaning you don't get to peek inside, bestie, it's mysterious on purpose π
β and it's used in conjunction with asynchronous I/O operations.
Every single asynchronous operation uses one of these structures. And here's the rule: each one can only be used with a single operation at a time. No sharing, no multitasking that one handle, one op at a time fr fr π
Asynchronous operations are performed without blocking the calling application threads. That's the whole point, that's the slay. Instead, your app registers a callback function that gets executed when the operation is complete β whether it went great or it went terribly, doesn't matter, it still fires. And this callback will be executed exactly once. Not zero times, not two times. Once. periodt π
The asynchronous I/O framework also supports cancellation of operations that are already in progress (see nng_aio_cancel()), and it lets you set a maximum timeout for them to complete within (see nng_aio_set_timeout()). So you can yeet an op if it's taking too long, iconic behavior honestly π
It is also possible to initiate an asynchronous operation, and then wait for it to complete using nng_aio_wait(). Sometimes you just wanna sit there and wait for your lil guy, and that's valid π«Ά
These structures are created using nng_aio_alloc(), and destroyed using nng_aio_free(). Make them, use them, free them. The circle of life bestie π§
πΈ SEE ALSO πΈ
nng_aio_abort(3)nng_aio_alloc(3)nng_aio_cancel(3)nng_aio_count(3)nng_aio_free(3)nng_aio_get_input(3)nng_aio_get_msg(3)nng_aio_get_output(3)nng_aio_result(3)nng_aio_set_input(3)nng_aio_set_iov(3)nng_aio_set_msg(3)nng_aio_set_timeout(3)nng_aio_stop(3)nng_aio_wait(3)nng_strerror(3)nng_aio(5)nng(7)
okay that's the whole page, you ate that π this was the NNG Reference Manual version, dated 2026-06-30, and we were literally just reading NNG_AIO(5). go forth and async responsibly, bestie ππ
π¦ where this page comes from
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms