= nng_dialer_create(3)
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This document is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

== NAME

nng_dialer_create - create dialer

== SYNOPSIS

[source, c]
----
#include <nng/nng.h>

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

== DESCRIPTION

The `nng_dialer_create()` function creates a newly initialized
<<nng_dialer.5#,`nng_dialer`>> object, associated with socket _s_,
and configured to connect to the
address specified by _url_, and stores a pointer to at the location
referenced by _dialerp_.

Dialers initiate a remote connection to a listener.
Upon a successful
connection being established, they create a pipe, add it to the socket,
and then wait for that pipe to be closed.
When the pipe is closed, they will re-initiate the connection.
Dialers will also periodically retry a connection automatically if
an attempt to connect asynchronously
fails.

TIP: While it is convenient to think of dialers as "`clients`", the relationship
between the listener or dialer is orthogonal to any server or client status
that might be associated with a given protocol.
For example, a <<nng_req.7#,_req_>>
socket might have associated dialers, but might also have associated listeners.
It may even have some of each at the same time!

The dialer is not started, but may be further configured with
the <<nng_dialer_setopt.3#,`nng_dialer_setopt()`>> family of functions.

Once it is fully configured, the dialer may be started using the
<<nng_dialer_start.3#,`nng_dialer_start()`>> function.

TIP: If no specific configuration is required, consider using the
simpler <<nng_dial.3#,`nng_dial()`>> function instead.

== RETURN VALUES

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

== ERRORS

`NNG_EADDRINVAL`:: An invalid _url_ was specified.
`NNG_ECLOSED`:: The socket _s_ is not open.
`NNG_ENOMEM`:: Insufficient memory is available.

== SEE ALSO

<<nng_dial.3#,nng_dial(3)>>,
<<nng_dialer_close.3#,nng_dialer_close(3)>>,
<<nng_dialer_getopt.3#,nng_dialer_getopt(3)>>,
<<nng_dialer_setopt.3#,nng_dialer_setopt(3)>>,
<<nng_dialer_start.3#,nng_dialer_start(3)>>,
<<nng_listener_create.3#,nng_listener_create(3)>>
<<nng_strerror.3#,nng_strerror(3)>>,
<<nng_dialer.5#,nng_dialer(5)>>,
<<nng.7#,nng(7)>>
