NNG_HTTP_SERVER_START(3http)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… 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:


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