NNG_CTX_OPEN(3)

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

πŸ’– NNG_CTX_OPEN(3) β€” the nng manual, but make it cute πŸ’–

okay bestie, pull up a chair, we're talking about nng_ctx_open β€” this one lives in the NNG Reference Manual and it's genuinely one of my faves, no cap. it's giving "let me spin you up a whole new context on an existing socket" and honestly? iconic. πŸ¦‹


✨ NAME ✨

nng_ctx_open β€” create context πŸ’…


🌸 SYNOPSIS 🌸

#include <nng/nng.h>

int nng_ctx_open(nng_ctx *ctxp, nng_socket s);

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea: nng_ctx_open() creates a separate context to be used with the socket s, and it returns that little baby at the location pointed to by ctxp. that's it, that's the whole vibe. πŸŽ€

Note β€” not every protocol supports creation of separate contexts, bestie. do not come for me when it doesn't. it's not me, it's the protocol. 😭

contexts let you use stateful operations independently and concurrently on the same socket. like, think about it: two different contexts created on a rep socket can each receive their own requests and send their own replies back, without any regard to β€” or interference with β€” each other. two main characters, one socket. zero drama. πŸ‘‘

TIP: using contexts is an excellent way to write simpler concurrent applications, while still retaining the benefits of the protocol-specific advanced processing β€” and it avoids the need to bypass all of that with raw mode sockets. so you get the cute high-level stuff AND the concurrency. slay.

Note β€” use of contexts with raw mode sockets is nonsensical and not supported. fr fr. don't do it. πŸ™ˆ

🫢 RETURN VALUES 🫢

this function returns 0 on success, and non-zero otherwise. that's the whole thing. periodt.


πŸ”₯ ERRORS πŸ”₯

  • NNG_ENOMEM β€” insufficient memory is available. your machine said "no thoughts, head empty". πŸ’€
  • NNG_ENOTSUP β€” the protocol does not support separate contexts, or the socket was opened in raw mode. either way: not supported, babe. πŸ™…β€β™€οΈ

🌈 SEE ALSO 🌈

nng_ctx_close(3), nng_ctx_getopt(3), nng_ctx_recv(3), nng_ctx_send(3), nng_ctx_setopt(3), nng_strerror(3), nng_ctx(5), nng_socket(5), nng_rep(7), nng_req(7), nng(7)


and that's the whole page, bestie!! πŸ’– this one's from the NNG Reference Manual, dated 2026-06-30, and it says NNG_CTX_OPEN(3) at the bottom too β€” so yeah, that's the source, the version, and the date all wrapped up with a bow. πŸŽ€ go forth and open some contexts, you've got this. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from