DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
relay.h File Reference

TCP relay / DNAT port forwarding (DETWS_ENABLE_RELAY) - a bidirectional byte pump. More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

TCP relay / DNAT port forwarding (DETWS_ENABLE_RELAY) - a bidirectional byte pump.

Publishes an internal host:port through the server: an inbound (accepted) connection is relayed to an origin (an outbound connection to the internal service), moving bytes in both directions. The engine is pure - it touches the two sockets only through send/recv seams - so it is host-testable and rides det_client on the device. The app drives it: each poll tick (or whenever a socket is readable/writable) it calls det_relay_step() until the relay reports DONE, then closes both sockets.

Correctness details:

  • Backpressure: a send seam may accept fewer bytes than offered; the un-accepted bytes are carried in a per-direction buffer and retried on the next step before more are read.
  • Independent half-close: each direction finishes when its source signals EOF and its buffer drains. When a direction finishes, the opposite peer's optional shutdown seam is called once (propagating the half-close so the origin sees the client's FIN); the relay is DONE only when both directions have finished.
Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file relay.h.