NNG_SEND_AIO(3)

πŸ“¦
version 1.12.0 Β· 4 versions
, in ubuntu stonking

✨ 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 a pub socket the data is broadcast, so that any peers who have a suitable subscription will be able to receive it using nng_recv() or a similar function.) Furthermore, some protocols may not support sending (such as sub), or may require other conditions. (For example, rep sockets 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 socket s is 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 socket s does not support sending. not every protocol has those skills, and that's okay πŸ’€
  • NNG_ESTATE β€” The socket s cannot 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