nbd_aio_connect_socket(3)

πŸ’… nbd_aio_connect_socket β€” bestie's guide to libnbd

okay so real talk, this page is nbd_aio_connect_socket(3) from the LIBNBD manual, and it's genuinely one of the cutest little connectors in the whole library. periodt. let's get into it πŸŽ€

✨ NAME ✨

nbd_aio_connect_socket β€” connect directly to a connected socket. that's it, that's the whole vibe πŸ¦‹

✨ SYNOPSIS ✨

#include <libnbd.h>

int nbd_aio_connect_socket (
      struct nbd_handle *h, int sock
    );

like, literally just hand it a handle and a socket and you're off πŸ’«

✨ DESCRIPTION ✨

okay so this is the begin connecting era of your life β€” the function starts connecting to the connected socket fd. ngl the parameters behave exactly as documented over in nbd_connect_socket(3), so if you're confused, that's your study material bestie πŸ“šβœ¨

✨ RETURN VALUE ✨

if the call is successful, it returns 0. slay. πŸŽ€

✨ ERRORS ✨

on error, -1 is returned. not slay. 😭

refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error β€” like, the actual tea on what went wrong πŸ’€

also heads up: the following parameters must not be NULL: h. for more info see "Non-NULL parameters" in libnbd(3). don't be the person who passes NULL, i'm begging πŸ™ˆ

✨ NOTES ✨

🌸 Asynchronous connect call 🌸

you can check if the connection attempt is still underway by calling nbd_aio_is_connecting(3) β€” very much "are we there yet" energy πŸš—πŸ’¨

if nbd_set_opt_mode(3) is enabled, the connection is ready for manual option negotiation once nbd_aio_is_negotiating(3) returns true 🧚 otherwise, the connection attempt will include the NBD handshake, and is ready for use once nbd_aio_is_ready(3) returns true πŸ‘‘

✨ HANDLE STATE ✨

vibe check time β€” nbd_aio_connect_socket can be called when the handle is in the following state:

  • Handle created, before connecting β€” βœ… allowed (this is your moment 🌈)
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” ❌ error
  • Connected to the server β€” ❌ error
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error πŸ’€

so like, one (1) state. the rest is a no. iykyk 🫢

✨ VERSION ✨

this function first appeared in libnbd 1.2. a classic, an icon, the moment πŸ‘‘

if you need to test if this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_AIO_CONNECT_SOCKET 1

✨ SEE ALSO ✨

go read these, they're literally all connected (pun intended):

✨ AUTHORS ✨

Eric Blake

Richard W.M. Jones

absolute legends, both of them 🌟

Copyright Red Hat

✨ LICENSE ✨

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


and that's the whole page bestie 🫢 this was libnbd-1.25.8, dated 2026-10-13, and the page itself is nbd_aio_connect_socket(3). go forth and connect responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from