NNG_HTTP_SERVER_START(3http)
π NNG_HTTP_SERVER_START (3http) β bestie's guide to starting your HTTP server
okay so this is a page straight out of the NNG Reference Manual β you know the vibe, it's the C library that does the networking so you don't have to π and today's main character is nng_http_server_start. Let's get into it π
β¨ SYNOPSIS β¨
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_server_start(nng_http_server *server);
that's it. one function. one argument. she's lowkey simple and that's why we love her π«Ά
πΈ DESCRIPTION πΈ
so nng_http_server_start() starts up the HTTP server instance you hand it in server. the way this works is: it makes the server bind to the appropriate TCP port, and then it starts accepting connections and handling HTTP requests. literally the glow-up moment where your server goes from "configured" to "actually doing stuff" π₯
think of it as the "go live" button, no cap. before this, your server is just sitting there with main character energy but zero plot. after this? she's serving π
π RETURN VALUES π
sweet and simple: this function returns 0 on success, and non-zero otherwise. so if you get 0, congrats bestie, you ate π
if you get anything else, go check the errors section below, iykyk.
π ERRORS π
here's the vibe check on what can go wrong β all of these are the non-zero return values, fr fr:
NNG_EADDRINUSEβ the TCP port is unavailable. someone else already claimed it π that port is taken, pick a different one or go find out who's squatting.NNG_EADDRINVALβ the server is configured with an invalid address. the address is giving nonsense, go fix your config πNNG_ENOMEMβ insufficient free memory exists. the machine is going through it, there's just not enough RAM to go around πNNG_ENOTSUPβ HTTP not supported. like, at all. this build can't do HTTP, periodt. nothing you can do from here.
ngl, NNG_ENOTSUP is the saddest one β it's not a typo, it's not a config issue on your end, HTTP just isn't there. check how your NNG was built before you lose your mind π§
π¦ SEE ALSO π¦
the whole friend group, go say hi:
nng_http_server_hold(3http)nng_http_server_release(3http)nng_http_server_stop(3http)nng_url_parse(3)nng_strerror(3)nng(7)
okay that's the whole page, you're officially an HTTP server starter π this cutie was brought to you by the NNG Reference Manual, dated 2026-01-13 β go forth and bind those ports bestie, ily, bye πβ¨π
π¦ 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