Is there any difference if we use “http://localhost:7001” instead of “http://127.0.0.1:7001” in NSMutableURLRequest/NSURLRequest while using an iPhone 4 device?
NSMutableURLRequest *request;
request = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://127.0.0.1:7001/"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60] autorelease];
Thanks
localhostrequires a DNS lookup. I presume iOS is smart enough to handle that lookup without consulting an external DNS server, but even so it takes some time. (And as @BoA notes, the lookup behavior can be locally reconfigured, though you shouldn’t have to worry about that on non-jailbroken devices.)If you’re explicitly connecting to the local device,
127.0.0.1should be faster and more reliable.