NNG_LISTENER_CREATE(3)

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

πŸ’– NAME πŸ’–

okay so bestie, nng_listener_create β€” it makes you a listener ✨ that's the whole vibe


🌸 SYNOPSIS 🌸

#include <nng/nng.h>

int nng_listener_create(nng_listener *listenerp, nng_socket s, const char *url);

πŸŽ€ DESCRIPTION πŸŽ€

so nng_listener_create() literally hands you a brand new, freshly initialized nng_listener object πŸ¦‹ β€” it's tied to the socket s, it's all set up to listen at the address you gave it in url, and it drops a pointer to that listener right where listenerp points. periodt.

what are listeners for, you ask? πŸ‘‘ they accept connections that remote dialers start. when a connection comes in, that generally means a pipe gets created and attached to socket s. and here's the iconic part: unlike dialers, listeners can generally make, like, so many pipes β€” and they can all be open at the same time. main character energy fr fr 🌈

✨ tip ✨ it's comfy to think of listeners as "the servers", but ngl β€” the listener/dialer thing is orthogonal to whatever server-or-client status a given protocol has. like, a req socket might have dialers, but it might also have listeners. it could even have some of each at the same time πŸ’… the vibes are flexible, iykyk.

so the listener is not started yet β€” not even a little. but you can keep configuring it with the nng_listener_setopt() family of functions 🫢

once it's fully configured and cute, you start it with nng_listener_start(). πŸš€

πŸ’œ tip β€” if you don't need any specific configuration at all, maybe just use the simpler nng_listen() function instead? it's giving low-effort, high-reward πŸ“

⭐ RETURN VALUES ⭐

  • 0 β€” slay, success πŸ’–
  • non-zero β€” not slay, something went wrong 😭

πŸ’€ ERRORS πŸ’€

  • NNG_EADDRINVAL β€” the url you gave was invalid. not it. πŸ™ˆ
  • NNG_ECLOSED β€” socket s is not open. bestie she's closed πŸ’€
  • NNG_ENOMEM β€” not enough memory available. the brain cell is empty 😭

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie πŸŽ€ this was the NNG_LISTENER_CREATE(3) page from the NNG Reference Manual, dated 2026-06-30 β€” go build something iconic with it βœ¨πŸ’…πŸ‘‘

πŸ“¦ where this page comes from