Re: Best practices for interpreting network reachability flags?
Re: Best practices for interpreting network reachability flags?
- Subject: Re: Best practices for interpreting network reachability flags?
- From: Rich Siegel <email@hidden>
- Date: Mon, 10 Sep 2007 10:18:23 -0400
On 9/10/07 at 10:09 AM, email@hidden (Allan Nathanson) wrote:
> >Yep, understood. Unfortunately, though: I'm having the opposite
> >problem: apparently I'm getting back (! (flags &
> >kSCNetworkFlagsReachable)) when the network is in fact connected and
> >running. Can you think of anything offhand that would explain that?
>
> If the flags do not indicate kSCNetworkFlagsReachable than for some
> reason we don't think that the target is currently network accessible.
That's what I figured.
> Are you using SCNetworkReachabilityCreateWith(Name|Address|AddressPair)?
I use SCNetworkReachabilityCreateWithName().
> If you are using SCNetworkReachabilityCreateWithName are you also using
> SCNetworkReachabilityScheduleWithRunLoop?
I am. My code flow goes like:
reachabilityRef = SCNetworkReachabilityCreateWithName(...);
if (NULL != reachabilityRef)
{
SCNetworkReachabilitySetCallback(...);
SCNetworkReachabilityScheduleWithRunLoop(reachability,
(CFRunLoopRef)(GetCFRunLoopFromEventLoop(GetMainEventLoop())),
kCFRunLoopCommonModes);
}
> If so, are you trying to get the flags just after you scheduled? If
> so, the flags will likely indicate not reachable while the DNS request
> is being processed and you'll get a callback when the request
> completes and we find that the flags changed and the target is
> reachable.
In the failing cases, I don't examine the flags until a number of
seconds (or minutes) after the reachability ref got scheduled on the
run loop. I've seen the behavior you describe (in which the
reachability ref doesn't have an answer right after it's scheduled),
but that situation doesn't apply to the symptoms I'm seeing.
Thanks,
R.
--
Rich Siegel Bare Bones Software, Inc.
<email@hidden> <http://www.barebones.com/>
Someday I'll look back on all this and laugh... until they sedate me.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden