Re: NSMutableURLRequest: Keeping the connection open
Re: NSMutableURLRequest: Keeping the connection open
- Subject: Re: NSMutableURLRequest: Keeping the connection open
- From: Thomas Engelmeier <email@hidden>
- Date: Fri, 01 Apr 2011 18:01:09 +0200
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