Re: Detecting network change
Re: Detecting network change
- Subject: Re: Detecting network change
- From: "Shawn Erickson" <email@hidden>
- Date: Thu, 23 Oct 2008 14:14:55 -0700
On Thu, Oct 23, 2008 at 1:31 PM, Greg <email@hidden> wrote:
>
> On Oct 21, 2008, at 4:56 PM, Jens Alfke wrote:
>
>> Use SystemConfiguration.framework to register for notifications when the
>> network configuration changes. There's sample code for both Mac and iPhone
>> showing how to use it.
>>
>> Note that this isn't magic — it will tell you if the user unplugged
>> Ethernet from the computer, but not if he unplugs the router's Ethernet
>> connection, or if workmen down the street accidentally cut his cable, or the
>> ISP's routers go down, or your server crashes, etc. In other words, it tells
>> you about things that happen on the computer, not elsewhere along the
>> network.
>>
>> —Jens
>
> OK, I've finally had a chance to work on this some, and I found two sample
> projects:
>
> SimpleReach (normal) and Reachability (iPhone specific)
>
> Neither example detects when the "network changes". They seem to detect
> when the network goes down, or up, but not if I hop from say, one access
> point to another (thereby getting a different IP address), which is what I
> need to be able to do.
>
> After looking through the SystemConfiguration documentation a bit, as well
> as the sample code, I'm not sure if I saw anything that would enable me to
> do this...
You have the ability to watch values in the dynamic store and get
notifications (callbacks) when they change. Review the document I
linked for information about notifications and also the schema so you
know what keys to watch / probe.
Also look at the following API...
SCDynamicStoreCreateWithOptions / SCDynamicStoreCreate
SCDynamicStoreCreateRunLoopSource
SCDynamicStoreSetNotificationKeys
-Shawn
_______________________________________________
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