Re: CFReadStream and iPhone
Re: CFReadStream and iPhone
- Subject: Re: CFReadStream and iPhone
- From: Jeremy Wyld <email@hidden>
- Date: Wed, 18 Feb 2009 09:15:42 -0800
On Feb 18, 2009, at 8:59 AM, Jens Alfke wrote:
On Feb 18, 2009, at 7:35 AM, John Michael Zorko wrote:
once connectivity is established and the CFReadStream is created, I
don't get any errors back from the CFReadStream when the network
changes (and I would think I would i.e. the connection would be
dropped, right)?
Nope. The socket won't be disconnected until/unless it sends packets
and doesn't receive ACKs for them, or it times out through lack of
activity (something like 2 hours.)
TCP is designed to be tolerant to temporary network interruptions,
so even if an interface goes down, sockets will stay alive waiting
for a route to reappear to the destination.
For example, if you're on Ethernet you can unplug the cable, wait
ten seconds or so, and then plug it back in without interrupting
sockets. However, applications like Mail and iChat will notice that
the interface is down and decide to pro-actively close their
sockets, as part of their mobility support. Your app can do
likewise, by registering for reachability notifications for the
destination IP address, and disconnecting if notified that it's
unreachable.
This is NOT how CFStream works. It's supposed to be killing the
stream when the route is affected by interface changes. This is true
on the Desktop or on the Phone.
That being said, the Phone has slightly different behavior. A stream
established on cell will be maintained on cell until cell is either
lost or the connection is closed. This is done in order to prevent
the sorts of failures a user would get when they roam into a WiFi hot
spot. Of course, the reverse can not be made true.
A good client performing data transfer should watch the reachability
of the host and switch at the earliest convenience when the host
reachability has switched from cell to WiFi. Watch for the change in
kSCNetworkReachabilityFlagsIsWWAN. When this flag is set, you're on
cell.
jeremy
_______________________________________________
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