iPv6 Network not available issue

+ (instancetype)  reachabilityForInternetConnection
{

Reachability *reach = NULL;
NetworkStatus status = NotReachable;

struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;

reach = [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress];

if  (reach != NULL)
{

status = [reach currentReachabilityStatus];

if (status != NotReachable)
{

NSLog(@”Connected to Ipv4 Environment”);

return reach;

}

}

if  ([[UIDevice currentDevice].systemVersion floatValue] < 9.0)
{

// check whether you are in iPv6 environment

struct sockaddr_in6 zeroAddress1;
bzero(&zeroAddress1, sizeof(zeroAddress1));
zeroAddress1.sin6_len = sizeof(zeroAddress1);
zeroAddress1.sin6_family = AF_INET6;

reach = [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress1];

if  (reach != NULL)
{

status = [reach currentReachabilityStatus];

if (status != NotReachable)
{

NSLog(@”Connected to Ipv6 Environment”);

}

}

}

return reach;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: