NNG_HTTP_CONN_READ(3http)
π 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 callnng_aio_set_iov()first to set the scatter/gather vector foraio. 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β theaiodoes 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 β
nng_aio_alloc(3)nng_aio_count(3)nng_aio_result(3)nng_aio_set_iov(3)nng_http_handler_alloc(3http)nng_http_client_connect(3http)nng_http_conn_read_all(3http)nng_strerror(3)nng(7)
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
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms