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

Layer 4 outbound TCP client transport (pooled). See client.h. More...

#include "client.h"

Go to the source code of this file.

Functions

int det_client_open (const char *, uint16_t, uint32_t)
 Resolve host (dotted-quad fast path, else DNS) and connect to host : port, blocking up to timeout_ms.
 
bool det_client_connected (int)
 True once the TCP handshake has completed for cid.
 
bool det_client_is_closed (int)
 True once the peer closed (FIN) or the connection errored.
 
bool det_client_send (int, const void *, size_t)
 Queue len wire bytes for transmission (marshaled tcp_write + output).
 
size_t det_client_available (int)
 Wire bytes currently buffered and ready to read.
 
size_t det_client_read (int, uint8_t *, size_t)
 Drain up to cap buffered wire bytes into buf; returns the count.
 
void det_client_close (int)
 Tear down the connection (marshaled) and return the slot to the pool.
 

Detailed Description

Layer 4 outbound TCP client transport (pooled). See client.h.

Mirrors the server transport's cross-thread rule: every raw lwIP call runs in tcpip_thread via tcpip_api_call(). Each slot owns its pcb and an SPSC wire ring (producer = the lwIP recv callback in tcpip_thread; consumer = the caller's loop/blocking task). The rings use volatile indices, matching the shipped per-client implementations this consolidates.

Definition in file client.cpp.

Function Documentation

◆ det_client_open()

int det_client_open ( const char *  host,
uint16_t  port,
uint32_t  timeout_ms 
)

Resolve host (dotted-quad fast path, else DNS) and connect to host : port, blocking up to timeout_ms.

Returns
A client id in [0, DETWS_CLIENT_CONNS) on success, or < 0 on failure (pool full, DNS failure, connect timeout/refused).

Definition at line 310 of file client.cpp.

◆ det_client_connected()

bool det_client_connected ( int  cid)

True once the TCP handshake has completed for cid.

Definition at line 314 of file client.cpp.

◆ det_client_is_closed()

bool det_client_is_closed ( int  cid)

True once the peer closed (FIN) or the connection errored.

Definition at line 318 of file client.cpp.

◆ det_client_send()

bool det_client_send ( int  cid,
const void *  data,
size_t  len 
)

Queue len wire bytes for transmission (marshaled tcp_write + output).

Definition at line 322 of file client.cpp.

◆ det_client_available()

size_t det_client_available ( int  cid)

Wire bytes currently buffered and ready to read.

Definition at line 326 of file client.cpp.

◆ det_client_read()

size_t det_client_read ( int  cid,
uint8_t *  buf,
size_t  cap 
)

Drain up to cap buffered wire bytes into buf; returns the count.

Definition at line 330 of file client.cpp.

◆ det_client_close()

void det_client_close ( int  cid)

Tear down the connection (marshaled) and return the slot to the pool.

Definition at line 334 of file client.cpp.