1

So I need to retrieve the user's WAN IP from within the app I am building. I saw this answer here: iPhone/iPad/OSX: How to get my IP address programmatically?

But this only returns the user's IP address in the local network.

By what means can I know the user's WAN IP from within the app?

4

1 回答 1

1

获取您的 wap ip 地址的最简单方法是使用NSURLConnection.

您可以使用的 URL:http: //www.whatismyip.com/m/mobile.asphttp://www.dyndns.org/cgi-bin/check_ip.cgi

只需解析返回数据,您就有了外部 IP 地址。这里展示了一个完整的实现。这不是最有效的方法,但它确实有效。

于 2013-11-05T15:01:30.600 回答