= nng_dialer_start_aio(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_start_aio - start dialer with an asynchronous I/O handle

== SYNOPSIS

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

int nng_dialer_start_aio(nng_dialer d, int flags, nng_aio *aiop);
----

== DESCRIPTION

The `nng_dialer_start_aio()` function starts the dialer _d_ using the
explicit asynchronous I/O operation handle _aiop_.

This causes the dialer to asynchronously start connecting to the address with
which it was created.

When a connection is established, it results in a pipe being created,
which will be attached to the dialer's socket.

This function must be called with `NNG_FLAG_NONBLOCK` set in _flags_ to
indicate that the connection attempt should be made asynchronously. Failing to
do so will return `NNG_EINVAL`.

When the dialer finishes dialing, it invokes
xref:nng_aio_finish.3.adoc[`nng_aio_finish()`] with the dialing result. Only
the first dialing result is communicated this way.

Once a dialer has started, it is generally not possible to change
its configuration.

== RETURN VALUES

None. (The operation completes asynchronously.)

== ERRORS

[horizontal]
`NNG_EADDRINVAL`:: An invalid _url_ was specified.
`NNG_ECLOSED`:: The socket _s_ is not open.
`NNG_ECONNREFUSED`:: The remote peer refused the connection.
`NNG_ECONNRESET`:: The remote peer reset the connection.
`NNG_EINVAL`:: An invalid set of _flags_ was specified.
`NNG_ENOENT`:: The dialer handle is invalid.
`NNG_ENOMEM`:: Insufficient memory is available.
`NNG_EPEERAUTH`:: Authentication or authorization failure.
`NNG_EPROTO`:: A protocol error occurred.
`NNG_ESTATE`:: The dialer _d_ is already started.
`NNG_EUNREACHABLE`:: The remote address is not reachable.

== SEE ALSO

[.text-left]
xref:nng_aio_result.3.adoc[nng_aio_result(3)]
xref:nng_dial.3.adoc[nng_dial(3)],
xref:nng_dialer_create.3.adoc[nng_dialer_create(3)]
xref:nng_dialer_start.3.adoc[nng_dialer_start(3)]
xref:nng_strerror.3.adoc[nng_strerror(3)],
xref:nng_dialer.5.adoc[nng_dialer(5)],
xref:nng.7.adoc[nng(7)]
