forlano Messages: 1100 Registered: March 2006 Location: Italy
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.
Oblivion Messages: 664 Registered: August 2007 Location: Turkey
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.