NNG_STREA...ENER_ALLOC(3str)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NAME πŸ’…

nng_stream_listener_alloc β€” the glow-up that allocates a byte stream listener ✨

okay so real quick bestie, this whole page lives in the NNG Reference Manual (nng fam, you already know), and it's literally just about making a listener. that's it. that's the vibe πŸŽ€


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_stream_listener_alloc(nng_stream_listener **lp, const char *addr);

int nng_stream_listener_alloc_url(nng_stream_listener **lp, const nng_url *url);

two flavors, same energy 🫢


🌸 DESCRIPTION 🌸

okay so these functions allocate a listener for byte streams, periodt. and what does a listener do? it makes nng_stream objects by accepting incoming connections through the nng_stream_listener_accept() function. that's the whole main character job description πŸ’…

the first form, nng_stream_listener_alloc(), connects to the address specified by addr β€” which should be a string representing a URL. yes, a string. put the URL in the string. iykyk πŸ’–

the second form, nng_stream_listener_alloc_url(), takes a pre-parsed or pre-constructed nng_url object to determine the remote address. so if you already did the parsing homework, this one's for you 🧚

these functions may support different URL schemes, such as ipc://, tcp://, tls+tcp://, or ws://. so many options, so little time πŸ”₯

and the important bit β€” both forms store the listener in the location referenced by lp. both of them. no exceptions. don't lose that pointer, bestie 😭


⭐ RETURN VALUES ⭐

these functions return 0 on success, and non-zero otherwise. that's it. 0 = slay, non-zero = check the errors section below πŸ‘‘


πŸ’€ ERRORS πŸ’€

  • NNG_ENOMEM β€” insufficient free memory exists. the vibe check failed, there's just not enough RAM to go around 😭
  • NNG_ENOTSUP β€” the URL scheme is not supported by the implementation. you asked for a scheme this build simply cannot serve, no cap πŸ™ˆ
  • NNG_EADDRINVAL β€” the URL requested is invalid. the URL is giving nothing, it's not valid πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

go read those next, bestie, the whole saga is right there πŸ“šβœ¨


and that's the page!! 🌈 this iconic little drop is from the NNG Reference Manual, dated 2026-01-13, filed under NNG_STREA...ENER_ALLOC(3str) β€” mwah, go allocate something gorgeous πŸ’œπŸŽ€

πŸ“¦ where this page comes from