One of my project uses the Apple\'s Reachability class in order to be monitor the network state and be notified in case of changes.
After reading this article about
I also have similar doubt regarding IPv6 and Reachability class. Apple has asked in their docs to provide support for IPv6 types also like (struct in_addr6, AF_INET6, struct sockaddr_in6 etc)
but the class seem to be not updated yet to have these types. This is the doubt that I am having. I am yet to try IPv6 tests but just observed while doing the static code checks. Some changes might be required.
Reachability.m
+ (instancetype)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
return [self reachabilityWithAddress:&zeroAddress];
}
Short answer from Apple itself (https://developer.apple.com/videos/play/wwdc2015/719/ at ~10:30 - though I would recommend to watch the video in full - or at least look through at the key points here: http://www.internetsociety.org/deploy360/blog/2015/06/video-of-apple-wwdc-session-about-ipv6-and-ios-9-now-available-and-some-screenshots/):
Just Try The Connection.
A copy paste from https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html#//apple_ref/doc/uid/TP40010220-CH213-SW25 which reiterates this:
Connect Without Preflight
The Reachability APIs (see SCNetworkReachability Reference) are intended for diagnostic purposes after identifying a connectivity issue. Many apps incorrectly use these APIs to proactively check for an Internet connection by calling the SCNetworkReachabilityCreateWithAddress method and passing it an IPv4 address of 0.0.0.0, which indicates that there is a router on the network. However, the presence of a router doesn’t guarantee that an Internet connection exists. In general, avoid preflighting network reachability. Just try to make a connection and gracefully handle failures. If you must check for network availability, avoid calling the SCNetworkReachabilityCreateWithAddress method. Call the SCNetworkReachabilityCreateWithName method and pass it a hostname instead.
Some apps also pass the SCNetworkReachabilityCreateWithAddress method an IPv4 address of 169.254.0.0, a self-assigned link-local address, to check for an active Wi-Fi connection. To check for Wi-Fi or cellular connectivity, look for the network reachability flag kSCNetworkReachabilityFlagsIsWWAN instead.