NNG_STREAM_LISTENER_LISTEN(3str)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’– NAME πŸ’–

okay bestie, welcome to the nng_stream_listener_listen page from the NNG Reference Manual β€” manual name NNG_STREAM...NER_LISTEN(3str), and she's iconic. The whole assignment is literally bind listener to configured address. No cap. ✨

✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_stream_listener_listen(nng_stream_listener *l);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so nng_stream_listener_listen() attempts to bind the listener l to the local address specified when the listener was created. That's the main character energy of this function. πŸ’…

This must generally be done before accepting incoming connections using nng_stream_listener_accept(). Like, bind first, then accept β€” that's the vibe check. 😌

For some transports this will also perform other actions. For example, with TCP listeners it will configure the underlying port into passive mode, ready to accept an incoming connection, and set up a listen queue for receiving incoming connections. TCP listener said "I'm ready for my close-up." 🎬

If binding the listener requires allocation of an address β€” for example, when a TCP port number of zero is specified, indicating that an ephemeral port should be used β€” this operation will allocate that resource. This can permit retrieval of the selected address using nng_stream_listener_get(), typically with the NNG_OPT_LOCADDR option. So yes, she can allocate the address resource and later tell you which address got picked. πŸŽ€

πŸ’… RETURN VALUES πŸ’…

This function returns 0 on success, and non-zero otherwise. Slay. ✨

πŸ”₯ ERRORS πŸ”₯

  • NNG_EADDRINUSE β€” the address is already in use. Someone else called dibs, bestie. πŸ™ˆ
  • NNG_EADDRINVAL β€” the address is invalid or unavailable. It's giving "invalid address" energy, fr fr. πŸ’€
  • NNG_ECLOSED β€” the listener has been closed. She's gone, periodt. 😭
  • NNG_ESTATE β€” the listener is already bound. Not me trying to bind twice, lowkey embarrassing. πŸ’…

🌈 SEE ALSO 🌈

go read these next, iykyk πŸ’–


xoxo, your Unix bestie πŸ’– β€” source/version: NNG Reference Manual; date: 2026-01-13; page: NNG_STREAM...NER_LISTEN(3str). mwah πŸ’‹

πŸ“¦ where this page comes from