https://www.codespeedy.com/check-internet-connection-in-c/
Проверяет пинги:
Код: Выделить всё
if (system("ping -c1 www.google.com"))
{
qDebug() <<"There is no internet connection \n";
}
else
qDebug() << "-> connection established!\n";
Код: Выделить всё
char *hostname;
struct hostent *hostinfo;
hostname = "google.com";
hostinfo = gethostbyname (hostname);
if (hostinfo == NULL)
{
cout <<"There is no internet connection \n";
}
else
cout << "-> connection established!\n";