Re: Network Reachability
Re: Network Reachability
- Subject: Re: Network Reachability
- From: Laurent Daudelin <email@hidden>
- Date: Fri, 29 Jan 2010 11:12:52 -0800
On Jan 28, 2010, at 22:38, Jens Alfke wrote:
>
> On Jan 28, 2010, at 9:22 PM, Laurent Daudelin wrote:
>
>> host = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef)hostName);
>> assert(host != NULL);
>>
>> SCNetworkReachabilityRef target = SCNetworkReachabilityCreateWithName(NULL, [hostName cStringUsingEncoding:NSUTF8StringEncoding]);
>
> It seems redundant to convert the hostname string into a CFHost and then back into a string. Have you verified that you're getting a reasonable C string at the end?
>
>> SCNetworkReachabilityGetFlags(target, &flags);
>
> Try checking the error code this returns. All the examples I've seen do this asynchronously by setting up a runloop-based callback; I'm not certain that the flags are valid immediately after you create the ref.
>
> —Jens
Jens,
The function doesn't return any error. I was able to determined that when the connection is down, I found out that kSCNetworkFlagsConnectionRequired was true, so it seems to work. It's just difficult to determine what exactly the flags mean. The examples CFHostSample and SimpleReach simply displays the value of the various flags returned.
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://nemesys.dyndns.org
Logiciels Nemesys Software email@hidden
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden