NNG_HTTP_CONN_READ(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NNG_HTTP_CONN_READ (3http)

okay so bestie, welcome to the nng_http_conn_read page from the NNG Reference Manual β€” yes, that NNG manual, the 3http section, and no cap it's a good one 🫢


✨ NAME ✨

nng_http_conn_read β€” read from an HTTP connection πŸŽ€


🌸 SYNOPSIS 🌸

#include <nng/nng.h>
#include <nng/supplemental/http/http.h>

void nng_http_conn_read(nng_http_conn *conn, nng_aio *aio);

literally that's the whole signature, she's tiny but she's powerful πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

So nng_http_conn_read() kicks off an asynchronous read from the HTTP connection conn, and it drops the data straight into the scatter/gather vector that lives inside the asynchronous I/O structure aio. ✨

🚨 Note, and this one actually matters: you must call nng_aio_set_iov() first to set the scatter/gather vector for aio. Like, before this function. Not after. iykyk πŸ’…

This function returns immediately and has no return value β€” that's the whole vibe, she doesn't wait around. Completion of the operation gets signaled through the aio, and you grab the final result with nng_aio_result(). That result is either zero or an error code. Simple as that, no cap.

The I/O operation completes as soon as at least one byte has been read, or an error has occurred. So yeah β€” the number of bytes read may be less than requested πŸ™ˆ (she's not going to fill your whole buffer just because you asked, that's not the assignment). You can find out the actual number of bytes read with nng_aio_count().

πŸ’‘ Tip: this function is intended to facilitate use cases that involve changing the protocol from HTTP β€” think WebSocket vibes. Most applications will never need to use this function. So if that's not you, feel free to scroll on, bestie. 😌

πŸ‘‘ RETURN VALUES πŸ‘‘

None. Nothing. Zero returns. She's asynchronous, she doesn't do that. πŸ’€


πŸ”₯ ERRORS πŸ”₯

Here's the full lineup of ways this can go sideways β€” every single one, no skipping 🧚

  • NNG_ECANCELED β€” the operation was canceled.
  • NNG_ECLOSED β€” the connection was closed.
  • NNG_ECONNRESET β€” the peer closed the connection. (rude, honestly 😭)
  • NNG_EINVAL β€” the aio does not contain a valid scatter/gather vector.
  • NNG_ENOMEM β€” insufficient free memory to perform the operation.
  • NNG_ENOTSUP β€” HTTP operations are not supported.
  • NNG_ETIMEDOUT β€” timeout waiting for data from the connection.

🌈 SEE ALSO 🌈

go read these too, they're all iconic in their own way ⭐


and that's the page, bestie!! πŸŽ€ this one's from the NNG Reference Manual, dated 2026-01-13, and the source/version line says NNG_HTTP_CONN_READ(3http) β€” so yeah, that's the whole manual-page moment, slay πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from