ESPHome 2026.4.3
Loading...
Searching...
No Matches
lwip_fast_select.h File Reference

Go to the source code of this file.

Enumerations

enum  { ESPHOME_LWIP_SOCK_RCVEVENT_OFFSET = 8 }
 

Functions

struct lwip_sock * esphome_lwip_get_sock (int fd)
 Look up a LwIP socket struct from a file descriptor.
 
void esphome_lwip_hook_socket (struct lwip_sock *sock)
 Hook a socket's netconn callback to notify the main loop task on receive events.
 
bool esphome_lwip_set_nodelay (struct lwip_sock *sock, bool enable)
 Set or clear TCP_NODELAY on a socket's tcp_pcb directly.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ESPHOME_LWIP_SOCK_RCVEVENT_OFFSET 

Definition at line 17 of file lwip_fast_select.h.

Function Documentation

◆ esphome_lwip_get_sock()

struct lwip_sock * esphome_lwip_get_sock ( int fd)

Look up a LwIP socket struct from a file descriptor.

Returns NULL if fd is invalid or the socket/netconn is not initialized. Use this at registration time to cache the pointer for esphome_lwip_socket_has_data().

Definition at line 196 of file lwip_fast_select.c.

◆ esphome_lwip_hook_socket()

void esphome_lwip_hook_socket ( struct lwip_sock * sock)

Hook a socket's netconn callback to notify the main loop task on receive events.

Wraps the original event_callback with one that also calls xTaskNotifyGive(). Must be called from the main loop after socket creation. The sock pointer must have been obtained from esphome_lwip_get_sock().

Definition at line 200 of file lwip_fast_select.c.

◆ esphome_lwip_set_nodelay()

bool esphome_lwip_set_nodelay ( struct lwip_sock * sock,
bool enable )

Set or clear TCP_NODELAY on a socket's tcp_pcb directly.

Must be called with the TCPIP core lock held (LwIPLock in C++). This bypasses lwip_setsockopt() overhead (socket lookups, switch cascade, hooks, refcounting) — just a direct pcb->flags bit set/clear. Returns true if successful, false if sock/conn/pcb is NULL or the socket is not TCP.

Definition at line 212 of file lwip_fast_select.c.