Skip to content

mDNS: add queryHost() - #9325

Merged
mcspr merged 2 commits into
esp8266:masterfrom
elbriga:feature-mdns-query-host
Nov 3, 2026
Merged

mcspr merged 2 commits into
esp8266:masterfrom
elbriga:feature-mdns-query-host

Conversation

@elbriga

@elbriga elbriga commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

Add MDNSResponder::queryHost() to ESP8266mDNS for resolving a host name to an IPv4 address using an mDNS A query.

This also improves API compatibility with the ESP32 ESPmDNS implementation, which already provides:

IPAddress MDNS.queryHost(const char *host, uint32_t timeout = 2000);

The implementation reuses the existing LEAmDNS query and answer infrastructure instead of introducing a separate DNS parser. The existing A-record processing is used to store the returned IPv4 address.

The query returns as soon as an IPv4 answer is received, or an empty IPAddress when the timeout expires.

The default timeout is 2000 ms, matching the ESP32 API.

Example

IPAddress ip = MDNS.queryHost("myhost");

if (ip.isSet()) {
    Serial.println(ip);
}

This resolves myhost.local.

Testing

Tested on ESP8266 hardware using the Arduino ESP8266 core through PlatformIO.

Verified that:

  • an existing .local host resolves to the expected IPv4 address;
  • the query returns before the timeout when an answer is received;
  • the API can be used with the same MDNS.queryHost() call used by the ESP32 implementation.

mcspr added a commit to mcspr/esp8266-Arduino that referenced this pull request Nov 3, 2026
adds missing function calls to the suspend/resume/wait chains
specifically helps out w/ cases like esp8266#9325, where blocking ops never succeed otherwise
@mcspr
mcspr merged commit 5dfdcce into esp8266:master Nov 3, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants