iOS: how to get the http connection's source port

无人久伴 提交于 2019-12-13 02:11:19

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!