AFNetworkReachabilityManager returns Accessible if not available

In my iOS app, I want to monitor the availability of multiple IP addresses on my network.

I tried to create multiple objects AFNetworkReachabilityManager

to monitor these IPs.

So, I create a manager like this:

var server_address = sockaddr_in(
    sin_len: __uint8_t(sizeof(sockaddr_in)),
    sin_family: sa_family_t(AF_INET),
    sin_port: in_port_t(80),
    sin_addr: in_addr(s_addr: inet_addr("10.0.0.60")),
    sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)
);

item.reachabilityManager = AFNetworkReachabilityManager(forAddress: &server_address);

      

The object item

has a property reachabilityManager

that stores the manager, rather than ending .

After initializing the manager, I set reachabilityStatusChangeBlock

for the manager as follows, I also started monitoring the manager.

item.reachabilityManager!.setReachabilityStatusChangeBlock({ (status) -> Void in

switch(status) {
    case AFNetworkReachabilityStatus.NotReachable, AFNetworkReachabilityStatus.Unknown:
        NSLog("UNREACHABLE: \(item.name)");
    case AFNetworkReachabilityStatus.ReachableViaWiFi, AFNetworkReachabilityStatus.ReachableViaWWAN:
        NSLog("REACHABLE \(item.name)");
}

});

item.reachabilityManager!.startMonitoring();

      

if i execute reachable

right after startMonitoring()

, it returns false , which i expect .

After that, mine starts reachabilityStatusChangeBlock

and it tells me that IP monitoring is available, while I know for sure that it is not (I am currently not in the same IP range and ping to this IP of course shows that there is no answer on the other end).

If I create an instance AFNetworkReachabilityManager

with an unknown domain name, it returns the status correctly. Therefore, I know that the manager is working correctly.

The only thing I can imagine calling this is a variable sockaddr_in

I am creating to use the dispatcher, perhaps I messed up one of the parameters from the constructor somewhere?

+3
ios swift afnetworking afnetworking-2


source to share


No one has answered this question yet

Check out similar questions:

1665
How can I get the UITextField to move upward when there is a keyboard - when starting editing?
17
Configuring Accessibility Using AFNetworking 2.0
6
Reachability monitoring with AFNetworking on presented controller only
five
AFNetworking's Availability for IP Address in Fast - Always Shared Reachability?
five
AFNetworkReachabilityManager says there is no network
3
AFNetworking Reachable not recognizing internet connection for the first time
2
AFNetworking Reachability Manager for Domain - Always Available Despite Unwitting Portal
1
AFNetworkReachabilityManager status unknown
1
Why is it available?
0
AFNetworkReachabilityManager in Swift



All Articles
Loading...
X
Show
Funny
Dev
Pics