Ping a host and check for reachability
So heres the code (Make sure you add the SystemConfiguration Framework in your project before you begin with this)
So heres the code (Make sure you add the SystemConfiguration Framework in your project before you begin with this)
- (BOOL)pinghosttoCheckNetworkStatus
{
bool success = false;
const char *host_name = [@"itunesconnect.apple.com"
cStringUsingEncoding:NSASCIIStringEncoding];
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL,host_name);
SCNetworkReachabilityFlags flags;
success = SCNetworkReachabilityGetFlags(reachability, &flags);
bool isAvailable = success && (flags & kSCNetworkFlagsReachable) &&
!(flags & kSCNetworkFlagsConnectionRequired);
if (isAvailable)
{
return YES;
}else{
return NO;
}
}
Comments
Post a Comment