ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
dns_server_esp32_idf.h
Go to the documentation of this file.
1#pragma once
3// ESP32 backend for CaptiveDNS: answers every A query with the access point address.
4#if defined(USE_ESP32) && (defined(USE_CAPTIVE_PORTAL) || defined(USE_WEBSERVER_CAPTIVE))
5
9
11
12class DNSServer {
13 public:
15 bool start(const network::IPAddress &ip);
16 void stop();
18
19 protected:
20 // No explicit close() needed — listen sockets have no active connections on
21 // failure/shutdown. Destructor handles fd cleanup (close or abort per platform).
22 inline void destroy_socket_() {
23 delete this->socket_;
24 this->socket_ = nullptr;
25 }
26 static constexpr size_t DNS_BUFFER_SIZE = 192;
27
31};
32
33} // namespace esphome::web_server_base
34
35#endif // USE_ESP32 && (USE_CAPTIVE_PORTAL || USE_WEBSERVER_CAPTIVE)
bool start(const network::IPAddress &ip)
Returns false when the socket could not be created or bound.