A little bit of an apology for re-posting this but I think my original post may have been too rambling so I have whittled it down to the bare question.
ESP8266 Arduino.
WiFi.hostByName usually returns in milliseconds successfully but sometimes takes several seconds and completes successfully or takes up to 8 seconds and returns without success.
My program comes to a complete halt while waiting for DNS lookup. That's OK for milliseconds but not OK for more than a second. I realize that there are parts of the network that are out of my control and I don't want my real-time activities to hang for more than a second because of a network glitch.
I know how to do non-blocking sockets but I do not know how to do non-blocking lookups.
Is there a non-blocking DNS lookup function, or a way to time-out a DNS lookup in a second or so, so my real-time activities can pick up again?
My current code fragment below.
IPAddress timeServerIP; // time.nist.gov NTP server address
const char* ntpServerName = "pool.ntp.org";
WiFi.hostByName(ntpServerName, timeServerIP);