This is a duplicate of this question. SCNetworkReachabilityGetFlags returns 0 even when wireless available
I tried all the solutions proposed in that post. But none of them worked for me.
SCNetworkReachabilityRef reachabilityRef = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
BOOL success = SCNetworkReachabilityGetFlags(reachabilityRef, &flags); //flags are always 0.
bool isAvailable = success && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired);
CFRelease(reachabilityRef);
if(isAvailable)
{
NSLog(@"Host is reachable: %d", flags);
}
else
{
NSLog(@"Host is unreachable");
}
I am trying to connect to a host via VPN. Can some one please suggest a workaround?