Snippet - Check Network Availablity without blocking

[title]Check Network Availablity without blocking[/title]
This snippet help you check if network is avalible by checking some public DNS (In example I use which is one of google DNS) without blocking whole device.

Thanks for sharing

Some feedback:

  1. Because of “time < _ping_timeout”, it will always block for at least 5 seconds even if the response was instant

  2. Without “time < _ping_timeout”, network_online_checking will not be set to true in time and the while loop will be skipped over before the thread has even started

I’d suggest replacing:


while (network_online_checking && time < _ping_timeout)


network_online_checking = true;

while (network_online_checking)

Link to new codeshare: