title: Reliable method to check internet connection in C++ application: gethostbyname() failing
body: <p>I am developing a C++ network application on Windows. I need to check if internet connection is there or not. I am using <code>gethostbyname()</code>, but it is giving incorrect information when the system is connected through a proxy. <code>InternetCheckConnection()</code> and <code>InternetGetConnectedState()</code> are also not giving reliable results under different conditions. Is there a reliable way to check for internet connectivity covering all the conditions such as proxy and VPN?</p>
  <p><strong>Update:</strong></p>
  <p>In our company network <code>WinHttpGetProxyForUrl()</code> is failing with the error <code>ERROR_WINHTTP_AUTODETECTION_FAILED</code> and <code>WinHttpSendrequest()</code> is failing with error <code>ERROR_WINHTTP_NAME_NOT_RESOLVED</code>.</p>
  <p>In open network <code>WinHttpSendrequest()</code> is successful.</p>