本文介绍了确定设备的公网IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道我能得到一个Android设备的公网IP​​地址?

Does anyone know how I could get the public ip address of an android device?

我想运行一个服务器套接字(只需用简单的P2P试验)。

I am trying to run a server socket (just experimenting with simple p2p).

这需要通知对方的公网IP​​的本地和远程用户。我发现这个线程如何获得设备的IP地址?,其中包含一个链接到一篇文章(http://www.droidnova.com/get-the-ip-address-of-your-device,304.html)演示了如何获取IP。然而,这将返回本地IP通过路由器连接,我想获得实际的公网IP​​,而不是时候。

This requires informing the local and remote users of each others public ip. I did find this thread How to get ip address of the device? which contains a link to an article (http://www.droidnova.com/get-the-ip-address-of-your-device,304.html) that shows how to get the IP. However this returns the local ip when connected through a router and I would like to get the actual public IP instead.

TIA

推荐答案

只需访问 HTTP:/ /automation.whatismyip.com/n09230945.asp 并刮了?

whatismyip.com 是完美的获取IP,但该网站的你只打了它大约每5分钟一次。

whatismyip.com is perfect for getting the IP, though the site requests you only hit it about once every 5 minutes.

更新2015年2月

WhatIsMyIp现在暴露了开发者API ,您可以使用。

WhatIsMyIp now exposes a developer API that you can use.

这篇关于确定设备的公网IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:59