获取套接字/网络接口的本地 IP 地址

发布于 2024-11-28 06:43:57 字数 217 浏览 8 评论 0 原文

我正在尝试为 Windows Phone 编写 VoIP 客户端,但找不到任何方法来获取手机的本地 IP 地址。我可以获取其公共 IP(通过 STUN 或访问 http://www.whatismyip.org/ 或类似网站),但如果双方位于同一本地网络,则所有连接尝试都会失败。有什么办法可以做到这一点吗?

I am trying to write a VoIP client for Windows Phone, and I can't find any way to get the phone's local IP Address. I can get its public IP (through STUN or visiting http://www.whatismyip.org/ or similar sites), but all connection attempts fail if both parties are on the same local network. Is there any way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

同展鸳鸯锦 2024-12-05 06:43:57

使用 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

千寻… 2024-12-05 06:43:57

您只能访问 HTTP 层。所以只有公共IP。

You have only access to the HTTP-Layer. So only the Public IP.

风尘浪孓 2024-12-05 06:43:57
Windows.Networking.Connectivity.NetworkInformation.GetHostNames()
Windows.Networking.Connectivity.NetworkInformation.GetHostNames()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文