nanomsg next generation NNG  
Home GitHub Documentation

This documentation is for version v1.1.0 of nng, but the latest released version is v1.3.2. see the documentation for v1.3.2 for the most up-to-date information.


#include <nng/nng.h>

void nng_ctx_recv(nng_ctx ctx, nng_aio *aio);


The nng_ctx_recv() receives a message using the context s asynchronously.

When a message is successfully received by the context, it is stored in the aio by an internal call equivalent to nng_aio_set_msg(), then the completion callback on the aio is executed. In this case, nng_aio_result() will return zero. The callback function is responsible for retrieving the message and disposing of it appropriately.

Failing to accept and dispose of messages in this case can lead to memory leaks.

If for some reason the asynchronous receive cannot be completed successfully (including by being canceled or timing out), then the callback will still be executed, but nng_aio_result() will be non-zero.

The semantics of what receiving a message means varies from protocol to protocol, so examination of the protocol documentation is encouraged.


None. (The operation completes asynchronously.)



The operation was aborted.


The context ctx is not open.


Insufficient memory is available.


The protocol for context ctx does not support receiving.


The context ctx cannot receive data in this state.


The receive timeout expired.

NNG Reference Manual vv1.1.0 © 2019 Staysail Systems, Inc, © 2018 Capitar IT Group BV
This document is supplied under the MIT License.
nanomsg™ and nng™ are trademarks of Garrett D'Amore.