Note that there are some explanatory texts on larger screens.

plurals
  1. POCFNetwork - Multiple Connections, Same Server?
    primarykey
    data
    text
    <p>I'm trying to create multiple connections to the same server (e.g. <a href="https://www.myserver.com/" rel="nofollow">https://www.myserver.com/</a>) using the CFNetwork framework. Everything works as expected when I try to make a single connection. As soon as I try adding a second concurrent connection, the second connection hangs and waits for the first to finish.</p> <p>I've tried adding the following code to "tag" the streams with unique ids (prior to opening the stream):</p> <pre><code>//self.httpReadStream is an NSInputStream //self.requestID is an NSNumber&lt;unsigned long long&gt; that increments with every new request CFReadStreamSetProperty((CFReadStreamRef)self.httpReadStream, CFSTR("StreamTag"), (CFNumberRef)self.requestID); </code></pre> <p>I got this idea from here: <a href="http://lists.apple.com/archives/macnetworkprog/2008/Dec/msg00001.html" rel="nofollow">Apple Mailing List: Overlapping requests on multiple persistent connections?</a></p> <p>Unfortunately, this does not work. </p> <p>Please help. How can I achieve multiple concurrent connections to the same server (host/port) with the CFNetwork framework? Please note, <strong>I cannot use NSURLConnection for a number of complicated reasons</strong> (outside the scope of this post).</p> <p><strong>UPDATE1:</strong></p> <p>To clarify. If I try to make two concurrent requests to the same server (<a href="https://www.myserver.com" rel="nofollow">https://www.myserver.com</a>) using the CFNetwork APIs (each request with its own thread and runloop -- provided by an NSOperation), the first request connects and transfers data, but the second request gets queued behind the first until the first is complete (the NSOperationQueue is set to manage 4 concurrent operations). </p> <p>Both will not transfer data at the same time from the same server. I can, however, make multiple concurrent request only if the servers are all different (different host names, <a href="https://www.myserver0.com/" rel="nofollow">https://www.myserver0.com/</a>, and <a href="https://www.myserver1.com/" rel="nofollow">https://www.myserver1.com/</a>)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload