Re: NSURLConnection weirdiness
Re: NSURLConnection weirdiness
- Subject: Re: NSURLConnection weirdiness
- From: Nava Carmon <email@hidden>
- Date: Sat, 29 May 2010 22:23:55 +0300
On May 29, 2010, at 10:12 PM, Jens Alfke wrote:
>
> On May 29, 2010, at 11:53 AM, Nava Carmon wrote:
>
>> When I initialize the NSURLConnection I define a timeout in my NSURLMutableRequest in order not to stuck the GUI and let the user to work with application. On timeout I get didFailWithError in NSURLConnectionDelegate and show a message that there was not response from the server and the user can continue working.
>
> If you’re running the NSURLConnection asynchronously (which I think you are, since you use a delegate), you can already unblock the UI and let the user continue to work. That’s a better design than waiting until the connection finishes, especially in a mobile app. (For example, my Twitter client returns to the timeline as soon as I press the Post button, and sends the post to the Twitter servers in the background.)
Yes, you're right, but the point is that it's a "GET" method and the user has to wait till he sees the desired data. I show kind of activity indicator, till it loads and parses. It's a customer requirement.
>
>> The matter is that the connection or underlying socket somehow is preserved and the connection with the server is not closed. So when I try to get another url from the same server I can't reach it since the server is still stuck with the previous problematic request!
>
> Hm. It’s true that CFNetwork uses HTTP keep-alive mode, where it can reuse a socket for multiple requests. But I don’t think it’ll send a second request on the same socket until the previous one is complete. (I.e. I don’t believe it supports pipelining.) Instead it should be opening a new socket while the first one is busy, up to a max of I think 4 sockets per host.
>
> I don’t know if there’s any way, using public API, to disable keep-alive. It’s possible using a lower-level API like CFStream would let you get around this. I would ask on the macnetworkprog list. (And make sure to mention that this is on iPhone, as the APIs aren’t exactly the same as on Mac.)
May be I should try some other API to get these xml files? detaching a thread and init a parser with URL? Would it be better approach in this case?
Nava Carmon
email@hidden
"Think good and it will be good!"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden