问题
I use NSURLRequest and NSURLConnection to access server:
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:self.url];
[request setHTTPMethod:@"PROPFIND"];
[request setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
...
NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[coon start];
I know we need a destination IP
and destination port
to connect server;
the question is:
how to get&set the source port
of my http connection? (just mean I need the local port of my HTTP connection); server need it for NAT settings. Any suggestion will be greatly appreciated.
Thanks.
回答1:
finally, I had to do some work to create my own custom HTTP, and then support for setting the sour port of the socket the HTTP used.
来源:https://stackoverflow.com/questions/18307216/ios-how-to-get-the-http-connections-source-port