NNG_SEND_AIO(3)
β¨ NNG_SEND_AIO(3) β¨
okay bestie, welcome to the NNG Reference Manual, page nng_send_aio π
π NAME π
nng_send_aio β send message asynchronously. yes, the async one. she doesn't wait around for anybody π
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
void nng_send_aio(nng_socket s, nng_aio *aio);
π¦ DESCRIPTION π¦
So. nng_send_aio() sends a message over the socket s, but likeβ¦ asynchronously. no blocking, no standing in line, no waiting on her. she said "I'll text you" and she MEANS it π«Ά
the message you're sending has to already be chilling on the aio beforehand β you set that up with nng_aio_set_msg(). and heads up, babes: this function assumes ownership of the message. it's not yours anymore. it's hers now. let it go π
if the message got successfully queued for delivery to the socket, the aio will be completed and nng_aio_result() will return zero. in that case the socket will dispose of the message once it's done with it. cleanup? handled. iconic behavior honestly β¨
Note π The operation will be completed, and the callback associated with the aio executed, as soon as the socket accepts the message for sending. This does not indicate that the message was actually delivered β it may still be buffered in the sending socket, buffered in the receiving socket, or in flight over physical media. so likeβ¦ "queued" is not "delivered", bestie. don't get it twisted π
if the operation fails for ANY reason β and yes that includes cancellation or timeout β then the aio callback will be executed and nng_aio_result() will return a non-zero error status. in that case, guess whose problem the message is again? yours. the callback has the responsibility to retrieve the message from the aio with nng_aio_get_msg() and dispose of it appropriately. that could mean retrying the send operation on the same socket or a different one, or deallocating the message with nng_msg_free(). your message, your moment, your cleanup π§Ή
Note π The semantics of what "sending a message" even means varies from protocol to protocol, so examination of the protocol documentation is encouraged. (For example, with apubsocket the data is broadcast, so that any peers who have a suitable subscription will be able to receive it usingnng_recv()or a similar function.) Furthermore, some protocols may not support sending (such assub), or may require other conditions. (For example,repsockets cannot normally send data, which are responses to requests, until they have first received a request.) it's giving "read the room, read the protocol docs" π
π RETURN VALUES π
None. (The operation completes asynchronously.) she doesn't do return values, she does vibes, and the vibes are asynchronous β¨
π ERRORS π
NNG_ECANCELEDβ The operation was aborted. πNNG_ECLOSEDβ The socketsis not open. πͺNNG_EMSGSIZEβ The message is too large. that thing is NOT fitting in the bag πNNG_ENOMEMβ Insufficient memory is available. πNNG_ENOTSUPβ The protocol for socketsdoes not support sending. not every protocol has those skills, and that's okay πNNG_ESTATEβ The socketscannot send data in this state. wrong era, wrong state, wrong time πNNG_ETIMEDOUTβ The send timeout expired. she waited. she was patient. it did not happen. β°
π SEE ALSO π
nng_aio_get_msg(3), nng_aio_set_msg(3), nng_msg_alloc(3), nng_strerror(3), nng_aio(5), nng_msg(5), nng_socket(5), nng(7)
and that's the whole page, bestie β no cap π«Ά this was NNG Reference Manual, NNG_SEND_AIO(3), source dated 2026-06-30. go forth and send asynchronously, you absolute main character π
πβ¨
π¦ 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