Reputation: 10818
I'm developing an iPhone app that uses the network. The iPhone communicate with my server via HTTP request and should work on WiFi and 3G.
I currently use NSURLConnection initWithRequest
to send async requests to my server and get responses (but I will soon move to work with ASIHTTPRequest
library)
One thing that I'm not sure about is,
What happens when user device goes from WiFi to 3G (or vice versa)?
I know that the same connection can't be used and new connection must be established.
But do I need to do something to handle this situation, or does NSURLConnection
handle it automatically?
For example if I sent a request and in the middle of getting the response the connection changes, what will happen with this request?
I saw Apple's Reachability example code, and I know I can use Reachability to detect network changes, but not sure how to handle those changes.
Upvotes: 0
Views: 921
Reputation: 21221
When the connection changes from 3G to WiFi, the current request will result in a failure status, and yes you will need to do something to re establish the connection (restart, resume, etc...)
Having said that, i am not sure, but i think ASIHTTPRequest
has a mechanism to fix these issues when you for example request to download a file
Upvotes: 2