nbd_aio_connect_uri(3)
π NAME π
nbd_aio_connect_uri β okay so this is the one that connects you to an NBD URI, and yes bestie it's the async version, we love a non-blocking icon π
(this whole page lives in section 3 of the manual for libnbd, iykyk)
β¨ SYNOPSIS β¨
#include <libnbd.h>
int nbd_aio_connect_uri (
struct nbd_handle *h, const char *uri
);
π¦ DESCRIPTION π¦
Okay so real talk: this kicks off a connection to the NBD URI uri. The parameters do exactly what they do in nbd_connect_uri(3) β same energy, same behavior, no cap. It's just the asynchronous glow-up of that call β¨
π RETURN VALUE π
If the call slays (i.e. succeeds), it returns 0. That's it. That's the whole vibe.
π ERRORS π
On error? -1 comes back and it's giving π.
To find out more about what went wrong, go read "ERROR HANDLING" in libnbd(3) β that's where the deets live.
Also important: these parameters are not allowed to be NULL: h, uri. For the full tea, check "Non-NULL parameters" in libnbd(3).
πΈ NOTES πΈ
π« Asynchronous connect call π«
So here's how you check on your connection attempt while it's still doing its thing β call nbd_aio_is_connecting(3), periodt.
And if nbd_set_opt_mode(3) is enabled, then the connection is ready for manual option negotiation as soon as nbd_aio_is_negotiating(3) returns true. If it's not enabled, then the connection attempt includes the whole NBD handshake, and it's ready to use once nbd_aio_is_ready(3) returns true. Two different vibes, both valid π«Ά
π HANDLE STATE π
nbd_aio_connect_uri can be called when the handle is in these states, and here's the rundown:
- Handle created, before connecting β β allowed (this is your moment, main character energy)
- Connecting β β error
- Connecting & handshaking (opt_mode) β β error
- Connected to the server β β error
- Connection shut down β β error
- Handle dead β β error
So basically: only before you've connected. Catch it early or don't catch it at all π§
β VERSION β
This function first appeared in libnbd 1.0 β an OG, honestly.
If you ever need to test at compile time whether this function is available, just check if this macro is defined:
#define LIBNBD_HAVE_NBD_AIO_CONNECT_URI 1
π₯ SEE ALSO π₯
nbd_aio_is_connecting(3)nbd_aio_is_negotiating(3)nbd_aio_is_ready(3)nbd_connect_uri(3)nbd_create(3)nbd_set_opt_mode(3)libnbd(3)https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.mdβ go read it, it's literally the URI spec π
π AUTHORS π
Eric Blake
Richard W.M. Jones
(absolute legends, both of them π)
πΈ COPYRIGHT πΈ
Copyright Red Hat
π LICENSE π
Bestie this part is all business but it matters, so here it is fully: this library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
okay that's the whole page bestie, go connect to something π β¨
This was libnbd-1.25.8, dated 2026-10-13, and the page itself is nbd_aio_connect_uri(3) β mwah, bye π«Άπ
π¦ where this page comes from
- centos-stream 10: libnbd-devel 1.25.8-1.el10 Β· LGPL-2.0-or-later AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms