[DNS] Fix hostByName returning negative values when lookup failed

`hostByName` does only return `1` on success, however it may return a negative value when lookup failed.
So need to check for the exact return value and not consider it a boolean return type.
This commit is contained in:
TD-er committed 2026-10-07 08:27:40 +02:00
1 parent 488cb70ba9
commit 050017b2b0
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ bool PingClass::ping(IPAddress dest, int16_t count) {
bool PingClass::ping(const char* host, int16_t count) {
IPAddress remote_addr;
if (WiFi.hostByName(host, remote_addr))
if (WiFi.hostByName(host, remote_addr) == 1)
return ping(remote_addr, count);
return false;
+1 -1
View File
@@ -1173,7 +1173,7 @@ bool HTTPClientLight::connect(void)
} else {
IPAddress remote_addr;
// Add include "ESP8266WiFi.h" for this to work
if (!WiFi.hostByName(_host.c_str(), remote_addr)) {
if (Network.hostByName(_host.c_str(), remote_addr) != 1) {
return false;
}
if(!_client->connect(remote_addr, _port, _connectTimeout)) {
@@ -335,7 +335,7 @@ int WiFiClientSecure_light::connect(const char* name, uint16_t port, int32_t tim
DEBUG_BSSL("connect(%s,%d)\n", name, port);
IPAddress remote_addr;
clearLastError();
if (!WiFi.hostByName(name, remote_addr)) {
if (Network.hostByName(name, remote_addr) != 1) {
DEBUG_BSSL("connect: Name loopup failure\n");
setLastError(ERR_CANT_RESOLVE_IP);
return 0;