ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
socket.h File Reference

Go to the source code of this file.

Namespaces

namespace  esphome
 
namespace  esphome::socket
 

Typedefs

using esphome::socket::Socket = BSDSocketImpl
 
using esphome::socket::ListenSocket = BSDSocketImpl
 
using esphome::socket::UDPSendSocket = BSDSocketImpl
 
using esphome::socket::UDPSocket = BSDSocketImpl
 

Functions

bool esphome::socket::socket_ready (struct lwip_sock *cached_sock)
 Shared ready() helper using cached lwip_sock pointer for direct rcvevent read.
 
struct lwip_sock * esphome::socket::hook_fd_for_fast_select (int fd)
 Resolve an fd to its lwip_sock and install the netconn event-callback hook so the main loop is woken by FreeRTOS task notifications when data arrives.
 
bool esphome::socket::socket_ready_fd (int fd, bool loop_monitored)
 Shared ready() helper for fd-based socket implementations.
 
std::unique_ptr< Socket > esphome::socket::socket (int domain, int type, int protocol)
 Create a socket of the given domain, type and protocol.
 
std::unique_ptr< Socket > esphome::socket::socket_ip (int type, int protocol)
 Create a socket in the newest available IP domain (IPv6 or IPv4) of the given type and protocol.
 
std::unique_ptr< Socket > esphome::socket::socket_loop_monitored (int domain, int type, int protocol)
 Create a socket and monitor it for data in the main loop.
 
std::unique_ptr< UDPSendSocket > esphome::socket::socket_udp_send (int domain, int protocol)
 Create a send-only UDP socket (socket_udp_send), a UDP socket with receive support (socket_udp), or a UDP socket monitored for data in the main loop (socket_udp_loop_monitored).
 
std::unique_ptr< UDPSocket > esphome::socket::socket_udp (int domain, int protocol)
 
std::unique_ptr< UDPSocket > esphome::socket::socket_udp_loop_monitored (int domain, int protocol)
 
std::unique_ptr< UDPSendSocket > esphome::socket::socket_ip_udp_send (int protocol)
 socket_udp* variants using the newest available IP domain.
 
std::unique_ptr< UDPSocket > esphome::socket::socket_ip_udp (int protocol)
 
std::unique_ptr< UDPSocket > esphome::socket::socket_ip_udp_loop_monitored (int protocol)
 
std::unique_ptr< ListenSocket > esphome::socket::socket_listen (int domain, int type, int protocol)
 Create a listening socket of the given domain, type and protocol.
 
std::unique_ptr< ListenSocket > esphome::socket::socket_listen_loop_monitored (int domain, int type, int protocol)
 
std::unique_ptr< ListenSocket > esphome::socket::socket_ip_loop_monitored (int type, int protocol)
 
socklen_t esphome::socket::set_sockaddr (struct sockaddr *addr, socklen_t addrlen, const char *ip_address, uint16_t port)
 Set a sockaddr to the specified address and port for the IP version used by socket_ip().
 
bool esphome::socket::sockaddr_to_ipv4 (const struct sockaddr *addr, uint32_t *out)
 Network order IPv4 of an AF_INET or v4 mapped AF_INET6 peer; false for anything else.
 
socklen_t esphome::socket::set_sockaddr (struct sockaddr *addr, socklen_t addrlen, const std::string &ip_address, uint16_t port)
 Convenience overload for std::string (backward compatible).
 
socklen_t esphome::socket::set_sockaddr_any (struct sockaddr *addr, socklen_t addrlen, uint16_t port)
 Set a sockaddr to the any address and specified port for the IP version used by socket_ip().
 
bool esphome::socket::join_multicast_group (UDPSocket *sock, const char *ip_address, uint32_t *if_index_out=nullptr)
 Join a multicast group on the given socket.
 
bool esphome::socket::set_ipv6_multicast_if (Socket *sock, uint32_t if_index_in=0)
 Configure the outgoing IPv6 multicast interface on the given socket.
 
ConnectPollResult esphome::socket::poll_connect (Socket &sock, int &err_out)
 Poll a connect() that returned EINPROGRESS.
 
size_t esphome::socket::format_sockaddr_to (const struct sockaddr *addr_ptr, socklen_t len, std::span< char, SOCKADDR_STR_LEN > buf)
 Format sockaddr into caller-provided buffer, returns length written (excluding null)
 

Variables

constexpr int esphome::socket::IP_DOMAIN = AF_INET6