What does zero sockaddr_in mean in SCNetworkReachabilityCreateWithAddress?

1.3k Views Asked by At

tonymillion 's Reachability has

+(Reachability *)reachabilityForInternetConnection 
{   
    struct sockaddr_in zeroAddress;
    bzero(&zeroAddress, sizeof(zeroAddress));
    zeroAddress.sin_len = sizeof(zeroAddress);
    zeroAddress.sin_family = AF_INET;

    return [self reachabilityWithAddress:&zeroAddress];
}

and AFNetworkReachabilityManager has

+ (instancetype)sharedManager {
    static AFNetworkReachabilityManager *_sharedManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        struct sockaddr_in address;
        bzero(&address, sizeof(address));
        address.sin_len = sizeof(address);
        address.sin_family = AF_INET;

        _sharedManager = [self managerForAddress:&address];
   });

which mean both recommend that this is the right way to check for internet connection.

But I think that in ONLY care that we are connected to the Wifi router, it DOES NOT care that the Wifi router has internet access, right ?

Some one says in How to check for network reachability on iOS in a non-blocking manner?

The first one tests whether it can reach google.com, while the second one simply checks whether there's any internet connection possible (which it thinks there is, even though there's packet loss).

is it true ?

1

There are 1 best solutions below

0
On

I believe you want to know what is zeroAddress in the above code section. It is the host address for which address you want to check reachability. See this link.