public static NetworkStatus RemoteHostStatus ()
{
NetworkReachabilityFlags flags;
bool reachable;
if (remoteHostReachability == null) {
remoteHostReachability = new NetworkReachability (HostName);
// Need to probe before we queue, or we wont get any meaningful values
// this only happens when you create NetworkReachability from a hostname
reachable = remoteHostReachability.TryGetFlags (out flags);
remoteHostReachability.SetNotification (OnChange);
remoteHostReachability.Schedule (CFRunLoop.Current, CFRunLoop.ModeDefault);
} else {
reachable = remoteHostReachability.TryGetFlags (out flags);
}
if (!reachable)
return NetworkStatus.NotReachable;
if (!IsReachableWithoutRequiringConnection (flags))
return NetworkStatus.NotReachable;
return (flags & NetworkReachabilityFlags.IsWWAN) != 0 ?
NetworkStatus.ReachableViaCarrierDataNetwork : NetworkStatus.ReachableViaWiFiNetwork;
}