Skip to content

Commit

Permalink
[wiring] network: pass hints with protocol = AF_UNSPEC and AI_ADDRCON…
Browse files Browse the repository at this point in the history
…FIG flag to getaddrinfo
  • Loading branch information
avtolstoy committed Mar 28, 2019
1 parent 9d3253b commit 8a38244
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wiring/src/spark_wiring_network.cpp
Expand Up @@ -99,9 +99,13 @@ IPAddress NetworkClass::resolve(const char* name) {
IPAddress addr;
#if HAL_USE_INET_HAL_POSIX
struct addrinfo *ai = nullptr;
const int r = getaddrinfo(name, nullptr, nullptr, &ai);
struct addrinfo hints = {};
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = AF_UNSPEC;
const int r = getaddrinfo(name, nullptr, &hints, &ai);
if (!r) {
bool ok = false;
// This is not really needed if AI_ADDRCONFIG is properly supported
bool ipv4 = network_ready(*this, NETWORK_READY_TYPE_IPV4, nullptr);
bool ipv6 = network_ready(*this, NETWORK_READY_TYPE_IPV6, nullptr);
for (auto cur = ai; cur != nullptr && !ok; cur = cur->ai_next) {
Expand Down

0 comments on commit 8a38244

Please sign in to comment.