Skip to content

Instantly share code, notes, and snippets.

@cemolcay
Created June 20, 2014 07:47
Show Gist options
  • Save cemolcay/45f9649c58796c92a3cc to your computer and use it in GitHub Desktop.
Save cemolcay/45f9649c58796c92a3cc to your computer and use it in GitHub Desktop.
//#include "unistd.h"
//#include "netdb.h"
- (BOOL)isNetworkAvailable {
char *hostname;
struct hostent *hostinfo;
hostname = "google.com";
hostinfo = gethostbyname (hostname);
if (hostinfo == NULL){
NSLog(@"-> no connection!\n");
return NO;
}
else{
NSLog(@"-> connection established!\n");
return YES;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment