NNG_DIALER_CREATE(3)

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

πŸ’– NNG_DIALER_CREATE(3) πŸ’–

okay bestie, welcome to the NNG Reference Manual β€” this one's all about nng_dialer_create, and it's lowkey iconic. let's get into it 🫢


✨ NAME ✨

nng_dialer_create β€” create a dialer, periodt.


✨ SYNOPSIS ✨

#include <nng/nng.h>

int nng_dialer_create(nng_dialer *dialerp, nng_socket s, const char *url);

✨ DESCRIPTION ✨

so nng_dialer_create() does the thing where it makes you a freshly initialized nng_dialer object πŸ’…. this new dialer is associated with the socket s, and it's all configured to connect to the address you hand it in url. then it stashes a pointer to that shiny new dialer at the location dialerp points at. cute, right?

now let's talk about what a dialer is, because this is where it gets good. dialers initiate a remote connection to a listener πŸ¦‹. the moment a connection actually gets established, they create a pipe, add it to the socket, and then just... vibe there waiting for that pipe to be closed. and when the pipe does close? they re-initiate the connection. no drama, no sulking, they just try again. they'll also periodically retry automatically whenever an attempt to connect asynchronously fails. it's giving ✨resilient✨

Tip πŸ’‘ β€” okay so it's super convenient to think of dialers as "the clients", but ngl that's a trap. the listener/dialer relationship is orthogonal to whatever server-or-client status a given protocol might have. like, a req socket can have associated dialers, but it can also have associated listeners. it may even have some of each at the same time!! main character energy fr fr.

so yeah β€” the dialer is not started yet. it's just sitting there, and you're free to configure it further with the nng_dialer_setopt() family of functions. get it looking right 🌸

and once it's fully configured, you start it with nng_dialer_start() and then it's off to the races πŸ‘‘

Tip πŸ’‘ β€” if you don't actually need any specific configuration, do yourself a favor and use the simpler nng_dial() function instead. iykyk.

✨ RETURN VALUES ✨

this function returns 0 on success, and non-zero otherwise. simple as πŸ’–


✨ ERRORS ✨

here's the lineup of ways it can go wrong, no cap:

  • NNG_EADDRINVAL β€” you gave it an invalid url. like, an address that just doesn't hit. 😭
  • NNG_ECLOSED β€” the socket s is not open. bestie it's closed, we can't work with that πŸ’€
  • NNG_ENOMEM β€” insufficient memory is available. the system said "no thoughts, head empty" πŸ™ˆ

✨ SEE ALSO ✨

go read these next, for real:

nng_dial(3), nng_dialer_close(3), nng_dialer_getopt(3), nng_dialer_setopt(3), nng_dialer_start(3), nng_listener_create(3), nng_strerror(3), nng_dialer(5), nng(7)


aaaand that's the whole page, bestie πŸŽ€ this was the NNG Reference Manual, dated 2026-06-30 β€” go forth and dial responsibly βœ¨πŸŒˆπŸ’œ

πŸ“¦ where this page comes from