forlano Messages: 1182 Registered: March 2006 Location: Italy
Senior Contributor
Hello,
do we have some way to check if we are connected to a working network?
It would be nice to have the solution for both windows and linux, but even a dirty solution (using Windows API) only for windows would be ok.
The easiest workaround that comes to my mind is trying to connect to a known network or host (such as google) and grabbing the socket errors if any.
İf a socket error occurs, simply check the errno for error number: ENETUNREACH on Linux, and WSAGetLastError() for WSAEHOSTUNREACH on Windows.