NNG_HTTP_CONN_WRITE_REQ(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’Œ nng_http_conn_write_req β€” write HTTP request πŸ’Œ

okay bestie, so this is a page from the NNG Reference Manual, and it's all about yeeting an HTTP request out the door asynchronously. buckle up πŸŽ€


✨ NAME ✨

nng_http_conn_write_req β€” write HTTP request. that's it, that's the whole vibe. πŸ’…


✨ SYNOPSIS ✨

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

void nng_http_conn_write_req(nng_http_conn *conn, nng_http_req *req,
    nng_aio *aio);

like, copy-paste it exactly, don't @ me πŸ™ˆ


✨ DESCRIPTION ✨

so nng_http_conn_write_req() starts an asynchronous write of the HTTP request req to the connection conn. πŸ¦‹

and it doesn't do half the job β€” the entire request gets sent. that means the headers, and if there's request body data present, that too, no cap. (also FYI, that request body can be set with nng_http_req_set_data() or nng_http_req_copy_data() β€” drop those in beforehand and you're golden ✨)

this function returns immediately, with no return value. like, it literally gives you nothing back at the call site. instead, completion of the operation is signaled via the aio, and the final result may be obtained via nng_aio_result(). and that result will either be zero or an error code β€” that's the whole range, bestie, simple as 🫢

πŸ’‘ Note β€” consider using the nng_http_client_transact() or nng_http_conn_transact() functions instead, which provide a simpler interface for performing a complete HTTP client transaction. lowkey they're the main character here, this function is more of a supporting role ngl πŸ‘‘

✨ RETURN VALUES ✨

None. literally nothing. it's a void function, she returns nothing and she's iconic for it πŸ’…


✨ ERRORS ✨

here's the guest list of error codes that can show up in your nng_aio_result() 😭

  • NNG_ECANCELED β€” the operation was canceled. someone pulled the plug.
  • NNG_ECLOSED β€” the connection was closed. rip.
  • NNG_ECONNRESET β€” the peer closed the connection. like they just hung up mid-convo, rude πŸ’€
  • NNG_ENOMEM β€” insufficient free memory to perform the operation. your RAM said "no ❀️"
  • NNG_ENOTSUP β€” HTTP operations are not supported. this build said "not my vibe" πŸ™ˆ
  • NNG_ETIMEDOUT β€” timeout waiting for data from the connection. she waited, she got nothing, she left. ⏰

✨ SEE ALSO ✨

go read these next, they're all linked and gorgeous 🌸


and that's the whole page, bestie!! πŸŽ€ this lil beauty is from the NNG Reference Manual, dated 2026-01-13 β€” so she's fresh, she's current, she's serving documentation realness. mwah πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from