|
DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
|
Layer 4 (Transport) — TCP connection pool, ring buffers, and lwIP integration. More...
#include "DetWebServerConfig.h"#include "freertos/FreeRTOS.h"#include "freertos/queue.h"#include "lwip/tcp.h"#include <Arduino.h>Go to the source code of this file.
Classes | |
| struct | TcpConn |
| A single TCP connection context. More... | |
| struct | TcpEvt |
| Event record posted from lwIP callbacks to the main-loop task. More... | |
| class | DeterministicAsyncTCP |
| Static-only facade over the raw lwIP TCP API. More... | |
Enumerations | |
| enum | ConnState { CONN_FREE , CONN_ACTIVE , CONN_CLOSING } |
| Lifecycle state of a connection pool slot. More... | |
| enum | EvtType { EVT_CONNECT , EVT_DATA , EVT_DISCONNECT , EVT_ERROR } |
| Type of connection event posted to the FreeRTOS event queue. More... | |
Variables | |
| TcpConn | conn_pool [MAX_CONNS] |
| Static pool of connection contexts. Defined in transport.cpp. | |
Layer 4 (Transport) — TCP connection pool, ring buffers, and lwIP integration.
Defines the static connection pool and the FreeRTOS event queue used to pass connection events from lwIP callbacks (running in tcpip_thread) to the Arduino main-loop task.
Concurrency model
| Context | Reads | Writes |
|---|---|---|
| lwIP callbacks | rx_head (to check full) | rx_buffer[], rx_head |
| Arduino loop | rx_buffer[], rx_tail | rx_tail |
rx_head and rx_tail are volatile to prevent the compiler from caching them across the inter-task boundary. The single-producer / single-consumer ring buffer design guarantees correctness without a mutex as long as writes to each index are atomic (true for 32-bit Xtensa).
Backpressure When the ring buffer is full, tcp_recved() is called with only the bytes actually copied — not p->tot_len. This shrinks the TCP receive window and applies backpressure to the sender rather than silently dropping data.
Definition in file transport.h.
| enum ConnState |
Lifecycle state of a connection pool slot.
Transitions:
CONN_FREE → CONN_ACTIVE : accept callback fires.CONN_ACTIVE → CONN_FREE : graceful close, error, or timeout.CONN_ACTIVE → CONN_CLOSING : (reserved for future half-close support). | Enumerator | |
|---|---|
| CONN_FREE | Slot is available; no PCB is attached. |
| CONN_ACTIVE | Live connection; PCB is valid. |
| CONN_CLOSING | FIN sent; waiting for final ACK (reserved). |
Definition at line 54 of file transport.h.
| enum EvtType |
Type of connection event posted to the FreeRTOS event queue.
Definition at line 90 of file transport.h.
Static pool of connection contexts. Defined in transport.cpp.
Definition at line 25 of file transport.cpp.
Referenced by DeterministicAsyncTCP::check_timeouts(), http_parse(), DeterministicAsyncTCP::init(), DetWebServer::send(), DetWebServer::send_empty(), sse_write(), DeterministicAsyncTCP::stop(), ws_close(), ws_parse(), and ws_send_frame().