• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableURLRequest: Keeping the connection open
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableURLRequest: Keeping the connection open


  • Subject: Re: NSMutableURLRequest: Keeping the connection open
  • From: Mark Pauley <email@hidden>
  • Date: Wed, 30 Mar 2011 11:23:27 -0700

On Mar 30, 2011, at 11:19 AM, Thomas Engelmeier wrote:

>
> On 30.03.2011, at 20: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.
>
> That's what I suspected..
>
>> 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.
>
> OK, I'll give it a try. Does the later mean I can run into big trouble (i.e. lenghty timeouts) with interrupted and re-established internet access and I'll have to carefully adjust and test the code for reachability transition corner cases?
No: the HTTPReadStream mechanism is aware of network change events.  Your stream will fail early when the reachability changes and you will receive some connection lost type of error (Quinn would be more aware of these details).  In that case, you should then monitor reachability as normal and only attempt to connect to the endpoint again when you receive a notification that said endpoint is now reachable.

The big trouble comes when your server decides to sleep on a request.  In this case, all requests behind the current (sleeping) one will be blocked until the current response is completed.

>
> TIA,
> 	Tom_E
>

 _______________________________________________
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

References: 
 >NSMutableURLRequest: Keeping the connection open (From: Thomas Engelmeier <email@hidden>)
 >Re: NSMutableURLRequest: Keeping the connection open (From: Mark Pauley <email@hidden>)
 >Re: NSMutableURLRequest: Keeping the connection open (From: Thomas Engelmeier <email@hidden>)

  • Prev by Date: Re: NSMutableURLRequest: Keeping the connection open
  • Next by Date: Re: NSMutableURLRequest: Keeping the connection open
  • Previous by thread: Re: NSMutableURLRequest: Keeping the connection open
  • Next by thread: Re: NSMutableURLRequest: Keeping the connection open
  • Index(es):
    • Date
    • Thread