• 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: Overlapping requests on multiple persistent connections?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overlapping requests on multiple persistent connections?


  • Subject: Re: Overlapping requests on multiple persistent connections?
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 28 Nov 2008 13:41:04 -0800


On Nov 28, 2008, at 7:58 AM, Michael Bernardo wrote:

I've followed the model used by sample code at "/Developer/Examples/Networking/Get Example" to get a single persistent connection working. I can verify that with single, serial requests, the connection is re-used.

This is a really old sample that predates the higher-level networking classes in Foundation. It still works, but these days if you want to use HTTP, you should almost certainly start with NSURLRequest / NSURLConnection, which do all the work for you, including managing multiple connections. These are the same classes that Safari uses.

The trouble starts when I try to send simultaneous overlapping requests. It seems that CFNetwork only creates a single underlying network connection, no matter how many simultaneous requests are outstanding.

Well, the code you're using manages the connections directly. A CFStream corresponds directly to a single TCP socket, and this sample code only creates one of them. If you wanted to change it to open multiple connections, you'd have to create multiple CFStreams, probably by creating multiple GetExampleDelegate objects.

But I strongly recommend you stop using this code and use NSURLConnection instead. There is a lot of complexity to HTTP that this example doesn't get into, which you'd have to implement yourself — things like SSL support, pipelining, caching, GZIP compression…

—Jens

PS: Hey, Quinn — should that example be deprecated or something? It still serves a purpose in case someone absolutely has to implement their own HTTP support for some reason, but 99% of developers shouldn't be using it. Instead there should be some examples using NSURLConnection (I couldn't find any, either there or in /D/E/Foundation.)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: Overlapping requests on multiple persistent connections?
      • From: Michael Bernardo <email@hidden>
References: 
 >Overlapping requests on multiple persistent connections? (From: Michael Bernardo <email@hidden>)

  • Prev by Date: Overlapping requests on multiple persistent connections?
  • Next by Date: Re: Overlapping requests on multiple persistent connections?
  • Previous by thread: Overlapping requests on multiple persistent connections?
  • Next by thread: Re: Overlapping requests on multiple persistent connections?
  • Index(es):
    • Date
    • Thread