2#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
15#ifdef USE_SOCKET_SELECT_SUPPORT
54 if (ip_address.find(
':') != std::string::npos) {
61 server->sin6_family = AF_INET6;
62 server->sin6_port = htons(port);
65 inet6_aton(ip_address.c_str(), &ip6);
66 memcpy(server->sin6_addr.un.u32_addr, ip6.addr,
sizeof(ip6.addr));
74 auto *server =
reinterpret_cast<sockaddr_in *
>(addr);
76 server->sin_family = AF_INET;
77 server->sin_addr.s_addr = inet_addr(ip_address.c_str());
78 server->sin_port = htons(port);
90 server->sin6_family = AF_INET6;
91 server->sin6_port = htons(port);
92 server->sin6_addr = IN6ADDR_ANY_INIT;
99 auto *server =
reinterpret_cast<sockaddr_in *
>(addr);
101 server->sin_family = AF_INET;
102 server->sin_addr.s_addr = ESPHOME_INADDR_ANY;
103 server->sin_port = htons(port);
bool is_socket_ready(int fd) const
Check if there's data available on a socket without blocking This function is thread-safe for reading...
bool ready() const
Check if socket has data ready to read For loop-monitored sockets, checks with the Application's sele...
virtual int get_fd() const
Get the underlying file descriptor (returns -1 if not supported)
bool loop_monitored_
Whether this socket is monitored by the event loop.
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.
std::unique_ptr< Socket > socket(int domain, int type, int protocol)
Create a socket of the given domain, type and protocol.
std::unique_ptr< Socket > socket_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().
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.
Providing packet encoding functions for exchanging data with a remote host.
Application App
Global storage of Application pointer - only one Application can exist.