Is there any way to check Internet Connection on Linux Ubuntu? Because this one is only for Windows-- programmatically check whether my machine has internet access or not
Or Using Poco libraries.
Is there any way to check Internet Connection on Linux Ubuntu? Because this one is only for Windows-- programmatically check whether my machine has internet access or not
Or Using Poco libraries.
You can use route command in Linux to check
FILE *output;
if(!(output = popen("/sbin/route -n | grep -c '^0\\.0\\.0\\.0'","r")))
{
return 1;
}
unsigned int i;
fscanf(output,"%u",&i);
if(i == 1)
cerr<<"There is internet connection\n";
else if(i == 0)
cerr<<"There is no internet connection\n";
pclose(output);
You can find more information about it here.