Created
May 12, 2016 17:53
-
-
Save wilsolutions/3466a0c6dc48b33fe1551aaf23a602c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)pingReachabilityInternal | |
{ | |
BOOL ignoresAdHocWiFi = NO; | |
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) | |
struct sockaddr_in6 ipAddress; | |
bzero(&ipAddress, sizeof(ipAddress)); | |
ipAddress.sin6_len = sizeof(ipAddress); | |
ipAddress.sin6_family = AF_INET6; | |
#else | |
struct sockaddr_in ipAddress; | |
bzero(&ipAddress, sizeof(ipAddress)); | |
ipAddress.sin_len = sizeof(ipAddress); | |
ipAddress.sin_family = AF_INET; | |
ipAddress.sin_addr.s_addr = htonl(ignoresAdHocWiFi ? INADDR_ANY : IN_LINKLOCALNETNUM); | |
#endif | |
// Recover reachability flags | |
SCNetworkReachabilityRef defaultRouteReachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (struct sockaddr *)&ipAddress); | |
BOOL didRetrieveFlags = SCNetworkReachabilityGetFlags(defaultRouteReachability, &connectionFlags); | |
CFRelease(defaultRouteReachability); | |
if (!didRetrieveFlags) | |
printf("Error. Could not recover network reachability flags\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment