9#ifdef USE_LWIP_FAST_SELECT
13#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
17#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
19#elif defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
21#elif defined(USE_SOCKET_IMPL_LWIP_TCP)
32#ifdef USE_SOCKET_IMPL_BSD_SOCKETS
35#elif defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
38#elif defined(USE_SOCKET_IMPL_LWIP_TCP)
43#ifdef USE_LWIP_FAST_SELECT
49 return cached_sock ==
nullptr || esphome_lwip_socket_has_data(cached_sock);
58 if (sock !=
nullptr) {
63#elif defined(USE_HOST)
84#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
86#ifdef USE_LWIP_FAST_SELECT
95std::unique_ptr<Socket>
socket(
int domain,
int type,
int protocol);
110#ifdef USE_SOCKET_IMPL_LWIP_TCP
117inline std::unique_ptr<ListenSocket>
socket_listen(
int domain,
int type,
int protocol) {
142 return set_sockaddr(addr, addrlen, ip_address.c_str(), port);
bool ready() const
Check if the socket has buffered data ready to read.
struct lwip_sock * cached_sock_
Connected socket implementation for LWIP raw TCP.
Listening socket implementation for LWIP raw TCP.
void esphome_lwip_hook_socket(struct lwip_sock *sock)
Hook a socket's netconn callback to notify the main loop task on receive events.
struct lwip_sock * esphome_lwip_get_sock(int fd)
Look up a LwIP socket struct from a file descriptor.
bool socket_ready(struct lwip_sock *cached_sock)
Shared ready() helper using cached lwip_sock pointer for direct rcvevent read.
socklen_t 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().
std::unique_ptr< 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.
size_t 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)
std::unique_ptr< ListenSocket > socket_listen(int domain, int type, int protocol)
Create a listening socket of the given domain, type and protocol.
std::unique_ptr< ListenSocket > socket_listen_loop_monitored(int domain, int type, int protocol)
std::unique_ptr< Socket > socket(int domain, int type, int protocol)
Create a socket of the given domain, type and protocol.
struct lwip_sock * 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 ...
bool socket_ready_fd(int fd, bool loop_monitored)
Shared ready() helper for fd-based socket implementations.
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().
std::unique_ptr< 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< ListenSocket > socket_ip_loop_monitored(int type, int protocol)