NNG_CTX_CLOSE(3)

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

nng_ctx_close(3) β€” the NNG Reference Manual page where we say bye-bye to a context πŸŽ€

okay bestie, gather round, because today we're learning how to close a context in NNG and honestly it's giving closure (literally) πŸ’…


✨ NAME ✨

nng_ctx_close β€” close context 🫢


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_ctx_close(nng_ctx ctx);

like, that's it. one function, one argument, iconic behavior πŸ‘‘


✨ DESCRIPTION ✨

so nng_ctx_close() closes the context ctx. that's the whole vibe. πŸ’–

but wait β€” plot twist β€” messages that have already been submitted for sending may be flushed or delivered, and whether that happens depends on the transport. so no, this isn't a "cancel everything instantly" button, it's more of a "we're wrapping up here" moment. no cap. 😌

after this call returns, if you try to use that context again? boom, you get NNG_ECLOSED. every time. it's over, babe. πŸ’€

and threads that were waiting on operations on the context at the moment this call runs may also come back with an NNG_ECLOSED result. so yeah, everyone's getting the news at the same time. group chat announcement energy fr fr πŸ“£

Note 🫧 closing the socket that's associated with ctx (as in, using nng_close()) also closes this context. so the context goes down with the ship. 🌊

✨ RETURN VALUES ✨

  • 0 on success β€” slay πŸ’š
  • non-zero otherwise β€” not slay 😭

✨ ERRORS ✨

  • NNG_ECLOSED β€” the context ctx is already closed or was never opened in the first place. she's gone, or she never existed. either way, nothing to close here bestie πŸ¦‹

✨ SEE ALSO ✨


and that's the page!! this was the NNG Reference Manual, dated 2026-06-30, and honestly? obsessed. go close your contexts responsibly, besties πŸ’œβœ¨

πŸ“¦ where this page comes from