获取套接字/网络接口的本地 IP 地址
我正在尝试为 Windows Phone 编写 VoIP 客户端,但找不到任何方法来获取手机的本地 IP 地址。我可以获取其公共 IP(通过 STUN 或访问 http://www.whatismyip.org/ 或类似网站),但如果双方位于同一本地网络,则所有连接尝试都会失败。有什么办法可以做到这一点吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 UdpAnySourceMulticastClient 可以解决此问题。
它会在本地网络中找到您的地址。当您仅位于 1 个路由器后面时,此方法非常有效。当有多个路由器时,您可以开始考虑一种更复杂的方法来解决网络问题。
仔细看看 Andy Pennell 的博客:
http://blogs.msdn.com/b/andypennell/archive/2011/08/11/finding-your-own-ip-address-on-windows-phone-mango.aspx
There is a solution to this problem using UdpAnySourceMulticastClient.
It finds your address within the local network. This works well when you are only behind 1 router. When there is more than one router you can start thinking to a more complex way to solve the networking problem.
Take a better look on Andy Pennell's blog:
http://blogs.msdn.com/b/andypennell/archive/2011/08/11/finding-your-own-ip-address-on-windows-phone-mango.aspx
您只能访问 HTTP 层。所以只有公共IP。
You have only access to the HTTP-Layer. So only the Public IP.