explaingit

cesanta/mongoose

12,785CAudience · developerComplexity · 4/5LicenseSetup · hard

TLDR

A tiny two-file C networking library for embedded devices and microcontrollers that provides HTTP, WebSocket, MQTT, TCP, and TLS 1.3 in one portable package, including its own TCP/IP stack for systems with no operating system.

Mindmap

mindmap
  root((repo))
    What it does
      Embedded networking
      HTTP WebSocket MQTT
      TLS 1.3 built in
    Integration
      Two files only
      Built-in TCP/IP stack
      lwIP Zephyr support
    Target Hardware
      STM32 NXP Microchip
      No OS required
    License
      GPLv2 open source
      Commercial option paid
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add an HTTP REST API to an STM32 or NXP microcontroller running without an operating system by copying just two files into your project

USE CASE 2

Build an MQTT IoT client on an embedded device with built-in TLS 1.3 encryption using an event-driven callback model

Tech stack

ClwIPZephyr

Getting it running

Difficulty · hard Time to first run · 1h+

Targets embedded microcontrollers, development requires a cross-compilation toolchain and target hardware or emulator.

Free to use in open-source projects under GPLv2, proprietary and commercial products require a separate paid commercial license.

In plain English

Mongoose is a networking library written in C that lets you add internet connectivity to embedded devices and microcontrollers. It provides the building blocks for HTTP servers and clients, WebSocket connections, MQTT messaging (commonly used in IoT devices), UDP and TCP communication, and built-in TLS 1.3 encryption. The library has been in use since 2004 and is described as running on systems ranging from commercial industrial equipment to hardware on the International Space Station. One of its main selling points is that it fits inside very small devices with tight memory constraints. Adding Mongoose to a project requires copying just two files: mongoose.c and mongoose.h. It ships with its own built-in TCP/IP stack, which means it can run on microcontrollers that have no operating system at all. For chips from STM32, NXP, Microchip, Texas Instruments, Renesas, and others with built-in Ethernet hardware, Mongoose can handle all networking without any additional libraries. It can also run on top of existing stacks like lwIP or Zephyr when those are already part of the system. Programming with Mongoose follows an event-driven pattern. You write a callback function that responds to different types of events (an incoming HTTP request, an MQTT message arriving, a connection closing), register it with an event manager, and run a polling loop. The README shows short examples: a web server that serves files from a directory, a REST endpoint that returns the current time, and an MQTT client that subscribes to one topic and echoes messages to another. Each example fits in roughly 20 lines of C. The library is dual-licensed: GPLv2 for open-source projects and a commercial license for proprietary products. It is cross-platform and also builds on Linux, macOS, and Windows, which makes development and testing on a workstation straightforward before deploying to a target device.

Copy-paste prompts

Prompt 1
Show me a minimal Mongoose HTTP server in C that serves a JSON status endpoint on an STM32 microcontroller with no operating system
Prompt 2
Write a Mongoose MQTT client in C that connects to a broker with TLS, subscribes to sensor/data, and echoes messages back to another topic
Prompt 3
How do I integrate Mongoose into a Zephyr RTOS project to add HTTPS client support, show me the Kconfig options and the connection handler skeleton
Open on GitHub → Explain another repo

← cesanta on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.