Skip to content

Instantly share code, notes, and snippets.

@devkral
Created January 3, 2012 19:26
Show Gist options
  • Save devkral/1556468 to your computer and use it in GitHub Desktop.
Save devkral/1556468 to your computer and use it in GitHub Desktop.
internet connection test
/** Checks internet connection by making a dns request.
* The returned result is the error number of
* the dns request attempt.
* zero = connection available
* Licence: do what you want with this code snippet
*/
#include <netdb.h>
int networkdnstest(char *testdnsname)
{
struct addrinfo *result;
int error=getaddrinfo(testdnsname,NULL,NULL,&result);
return error;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment