iPhone - check if internet connectivity is available or not -
I'm using the following code to figure out whether internet connectivity exists or not.
structure sockaddr_in zero address; Berboo (& amp; zero address, sizeof (zero address)); Zero address. Sin_len = sizeof (zeroedender); Zero Edender S_family = AF_INET; // Recover accessibility flags SCNetworkReachabilityRef default Advanced qualification = SCNetworkReachabilityCreateWithAddress (NULL, (struct sockaddr *) and zero address); SCNetworkReachability flag flags; BOOL Publish = SCNetworkReachabilityGetFlags (Default Routes, Eligibility, and Flags); CFRelease (defaultRouteReachability); If (had done!) "NSLog (@" error, network accessibility flag could not be corrected "); return 0;} BOOLReachable = flags & kSCNetworkFlagsReachable; BOOL needs connection = flags & kSCNetworkFlagsConnectionRequired;
When my device is connected to a wifi network, this method gives the expected result. But if I get 3G Or test the same method on the edge network, then nobody gives it (I.e. not connected to internet)
Why any thoughts?
Thanks.
The problem is that you are not actively connected, the cellular modem operates below (which it does after a few seconds inactivity). If you think you feel you need it So the connection is yes. Any connection between the high-level API (CFNetwork, NSURLConnection) will be automatically installed.
Come It can check to see that you have cellular available by checking for Kessian network Richaibilitiflagswatin key or not.
Comments
Post a Comment