سؤال

I try to use getaddrinfo() in my application which should determine whether I am connected to the internet. As long as getaddinfo() is able to return successfully everything is OK. But as soon as I disconnect my computer from the router the execution of the function fails and takes about 10 seconds.

Is there a solution to fix this or is there a better function to check whether I am connected to the internet or not?

Note: A similar question has already been asked here but disabling the DNSClient service didn't work for me.

هل كانت مفيدة؟

المحلول

The BOOL InternetGetConnectedState( Out LPDWORD lpdwFlags, In DWORD dwReserved ) function could be a good choice. Thanks to Damon.


The InternetGetConnectedState function exists for a reason. - @Damon

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top