NNG_CTX_OPEN(3)
π 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
- 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