Re: NSMutableURLRequest: Keeping the connection open
Re: NSMutableURLRequest: Keeping the connection open
- Subject: Re: NSMutableURLRequest: Keeping the connection open
- From: Laurent Daudelin <email@hidden>
- Date: Wed, 30 Mar 2011 11:30:23 -0700
I always appreciate having the comments of Apple engineers. Thank you, Mark.
-Laurent.
-- Laurent Daudelin
On Mar 30, 2011, at 11:06, Mark Pauley wrote: NSURLConnection closes sockets after a relatively short period in order to allow the system to power the antenna down more quickly, thus saving battery life. The loader can't know when you are 'done' communicating to the server, and you can't really tell the loader because the details of tcp connections are completely hidden from your client code.
If you absolutely must know about the underlying connections or if your app is hitting a pathologically bad case of socket management, feel free to drop down to CFHTTPReadStream, otherwise I would recommend that you not worry about the details of socket connections and just use NSURLConnection as is.
If you do decide to use CFHTTPReadStream: make sure you don't close the stream until after you open the next stream. This is how you can keep the underlying socket open. Also be advised that you only get one socket per host / port pair going that route unless you want to get more tricky.
|
_______________________________________________
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