ESPHome 2025.6.3
Loading...
Searching...
No Matches
esphome::socket Namespace Reference

Data Structures

class  Socket
 

Functions

std::string format_sockaddr (const struct sockaddr_storage &storage)
 
std::unique_ptr< Socketsocket (int domain, int type, int protocol)
 Create a socket of the given domain, type and protocol.
 
std::unique_ptr< Socketsocket_loop_monitored (int domain, int type, int protocol)
 Create a socket and monitor it for data in the main loop.
 
std::unique_ptr< Socketsocket_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< Socketsocket_ip_loop_monitored (int type, int protocol)
 
socklen_t set_sockaddr (struct sockaddr *addr, socklen_t addrlen, const std::string &ip_address, uint16_t port)
 Set a sockaddr to the specified address and port for the IP version used by socket_ip().
 
socklen_t 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().
 

Function Documentation

◆ format_sockaddr()

std::string esphome::socket::format_sockaddr ( const struct sockaddr_storage & storage)

Definition at line 18 of file bsd_sockets_impl.cpp.

◆ set_sockaddr()

socklen_t esphome::socket::set_sockaddr ( struct sockaddr * addr,
socklen_t addrlen,
const std::string & ip_address,
uint16_t port )

Set a sockaddr to the specified address and port for the IP version used by socket_ip().

Definition at line 52 of file socket.cpp.

◆ set_sockaddr_any()

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().

Definition at line 82 of file socket.cpp.

◆ socket()

std::unique_ptr< Socket > esphome::socket::socket ( int domain,
int type,
int protocol )

Create a socket of the given domain, type and protocol.

Definition at line 177 of file bsd_sockets_impl.cpp.

◆ socket_ip()

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.

Definition at line 36 of file socket.cpp.

◆ socket_ip_loop_monitored()

std::unique_ptr< Socket > esphome::socket::socket_ip_loop_monitored ( int type,
int protocol )

Definition at line 44 of file socket.cpp.

◆ socket_loop_monitored()

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.

Like socket() but also registers the socket with the Application's select() loop. WARNING: These functions are NOT thread-safe. They must only be called from the main loop as they register the socket file descriptor with the global Application instance. NOTE: On ESP platforms, FD_SETSIZE is typically 10, limiting the number of monitored sockets. File descriptors >= FD_SETSIZE will not be monitored and will log an error.

Definition at line 181 of file bsd_sockets_impl.cpp.