I'm trying to connect to a C# HTTP server with an iPhone app. Pretty simple code so far:
NSData *requestData = [ NSData dataWithBytes: [ requestMessage UTF8String ] length: [ requestMessage length ] ];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:infoURL]];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: requestData];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
The server gets the request, sends a response, and then terminates the connection. The iPhone reports connection reset by peer.
To be able to hit the server in Firefox on my desktop I need to go into it's advanced preffs and disabled keep-alive. The reason, I assume, is because I'm terminating the connection right after I sent the response. I do so because I don't want to reuse connections later.
Anyway to disable keep-alive when using NSURLConnection on the iPhone, or any suggestions on modifying my .Net code?