Nithin
Nithin

Reputation: 6475

Connection Time out in iphone for http requests

What is the connection time out in the case of iphones. How long will the compiler wait for a response after a request have been made??

Upvotes: 2

Views: 8197

Answers (2)

Jeff
Jeff

Reputation: 277

The default request timeout is 60 seconds, but you can change it for any URLRequest. In this example, I set the timeout to 15 seconds on an NSMutableURLRequest by calling setTimeoutInterval:

NSURL *url = [[NSURL alloc] initWithString:@"http://someurl.com"];

NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
[urlRequest setTimeoutInterval:15.0];

NSError *error;
NSURLResponse *response;
NSData *data = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];

Upvotes: 2

Andrew Kuklewicz
Andrew Kuklewicz

Reputation: 10701

Using NSURLConnection, the timeout is set in the NSURLRequest, and the default in the NSMutableURLRequest request is 60 seconds, and can be changed using the setTimeoutInterval method.

http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/Reference/Reference.html#//apple_ref/occ/instm/NSMutableURLRequest/setTimeoutInterval:

Upvotes: 4

Related Questions