Re: NSMutableURLRequest: Keeping the connection open
Re: NSMutableURLRequest: Keeping the connection open
- Subject: Re: NSMutableURLRequest: Keeping the connection open
- From: Mark Pauley <email@hidden>
- Date: Fri, 1 Apr 2011 16:20:38 -0700
Wait, do you see a new tcp handshake for each request? Did CFNetwork close the connection or is there just an SSL re-negotiation on each request?
On Apr 1, 2011, at 9:01 AM, Thomas Engelmeier wrote:
>
> On 30.03.2011, at 20:06, Mark Pauley wrote:
>
>> 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.
>
> Hmm, that is exactly what I tried now but get a SSL renegotiation in the packet dumps for each and every request. I double validated that CFRelease / CFReadStreamClose of the old stream is called only in that piece of code:
> (Target: iOS 4.3 simulator)
>
> Current code
>
> /// request setup snipped
>
> CFReadStreamRef oldStream = readStream;
>
> readStream = CFReadStreamCreateForHTTPRequest(NULL, aRequest);
> CFReadStreamSetProperty( readStream, kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue );
>
> CFStreamClientContext context = {0, self, NULL, NULL, NULL};
> CFReadStreamSetClient(readStream, kCFStreamEventHasBytesAvailable | kCFStreamEventEndEncountered | kCFStreamEventErrorOccurred, handleStreamEvent, &context);
> CFReadStreamScheduleWithRunLoop(readStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
> CFReadStreamOpen(readStream);
>
> if ( oldStream) {
> NSLog( @"overlapping create" );
> CFReadStreamClose(oldStream);
> CFReadStreamSetClient(oldStream, kCFStreamEventNone, NULL, NULL);
> CFReadStreamUnscheduleFromRunLoop(oldStream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
> CFRelease(oldStream);
> } else {
> NSLog( @"New stream!" );
> }
>
_______________________________________________
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