NNG_DIALER_CREATE(3)
π 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 invalidurl. like, an address that just doesn't hit. πNNG_ECLOSEDβ the socketsis 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
- ubuntu stonking: libnng-dev 1.12.0-1 Β· MIT OR Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms