NNG_LISTENER(5)

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

πŸ’– NNG_LISTENER(5) πŸ’–

okay so bestie, welcome to the nng_listener page from the NNG Reference Manual ✨ grab a snack, this one's short but it's lowkey foundational 🫢


✨ NAME ✨

nng_listener β€” listener πŸ‘‘ (yes that's the whole name, she's simple and she's iconic)


🌸 SYNOPSIS 🌸

#include <nng/nng.h>

typedef struct nng_listener_s nng_listener;

that's it. that's the whole thing. a typedef and a dream πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so an nng_listener is a handle to a listener object, and its whole job β€” her entire purpose, her main character arc β€” is creating nng_pipe objects by accepting incoming connections. 🌈

and like, not just one pipe. one single listener object can spin up many pipes at the same time, no cap. think of it like an HTTP server that's got a whole crowd of connections to a bunch of different clients all at once. she's popular, she's booked, she's thriving πŸ’–

listener objects get created by nng_listener_create() or nng_listen(), and they're always associated with a single nng_socket. one socket, one listener-buddy (well, per listener anyway, iykyk).

⚠️ Important β€” the nng_listener structure is always passed by value, both for input parameters and return values, and you should treat it as opaque. passing structs around like this is actually a glow-up because it gives the compiler a chance to do accurate type checks in functions that pass values of this type. so like, don't go poking at her insides, let the compiler do the vibes check πŸ”₯
πŸ’‘ Tip β€” a given nng_socket can have multiple listener objects, multiple dialer objects, or even some of both. mix and match, she contains multitudes ✨
πŸ’‘ Tip β€” the client/server relationship that dialer/listener describes is completely orthogonal to any similar relationship in the protocols. like fr fr, a rep socket may use a dialer to connect to a listener on an req socket. this orthogonality is genuinely a slay because it can lead to innovative solutions to otherwise challenging communications problems. not me being obsessed with this design 😭

listener objects may be destroyed by the nng_listener_close() function. they also get closed when their associated socket is closed β€” they're ride or die like that πŸ₯Ί

πŸŽ€ Initialization πŸŽ€

a listener may be initialized using the macro NNG_LISTENER_INITIALIZER before it is opened, so you don't confuse it with a valid open listener. do this. seriously. it's the self-care step πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page bestie, you ate it, go forth and accept some connections 🫢✨

this was the NNG Reference Manual version dated 2026-06-30, page NNG_LISTENER(5) β€” k byeeee πŸ’œπŸ§šπŸ“

πŸ“¦ where this page comes from