Re: Detecting network change
Re: Detecting network change
- Subject: Re: Detecting network change
- From: Greg <email@hidden>
- Date: Thu, 23 Oct 2008 17:51:46 -0400
On Oct 23, 2008, at 5:38 PM, Josh Graessley wrote:
The SCDynamicStore APIs are available on the desktop but not on the
iPhone/iPod Touch.
If you use SCNetworkReachabilityCreateWithName or
SCNetworkReachabilityCreateWithAddress for general reachability and
follow up with SCNetworkReachabilityCreateWithAddressPair when you
have established a connection,
SCNetworkReachabilityCreateWithAddressPair will notify you when the
local address is no longer useful. If you have access to the socket,
you can use getsockname and getpeername to get the values for
SCNetworkReachabilityCreateWithAddressPair. If you're using one of
those fancy high level frameworks, you may have no access to the
socket. Ideally there would be events directly on the socket to let
you know about changes that may be relevant or
SCNetworkReachabilityCreateWithSocket that would look at the state
of the connected socket and figure out the nitty gritty details.
-josh
Perfect. This sounds like exactly what I need. I'm using low-level
sockets and getsockname already so this should fit in neatly.
Ideally there would be events directly on the socket to let you know
about changes that may be relevant
I'm surprised by the current behavior of the sockets. I'm using
asynchronous sockets and calling recv() or send() on them does not
result in any serious error on errno after switching jumping networks,
which is bizarre and the reason I started looking outside the BSD
socket API in the first place. I'm curious as to why they don't do
that...
Thanks again for your reply, my plan is to modify the "Reachability"
example to use SCNetworkReachabilityCreateWithAddressPair(), if you
don't hear back from me it means everything worked! :-D
- Greg
_______________________________________________
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