获取 iPhone 上当前 Wi-Fi 接入点的 IP 地址?
I am trying to connect from my iPhone to a socket server running on the same network on my computer. How can I get the local IP address of the computer that is running the socket server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的服务器需要使用 mDNS 协议 进行自身广播。
然后在 iPhone 上,您只需使用
gethostbyname
即可获取 IP 地址。您还有一个特定的 API: DNS 服务发现 C 参考。Your server needs to broadcast itself using the mDNS protocol.
Then on the iPhone, you can simply use
gethostbyname
to get the IP address. You also have a specific API for that: DNS Service Discovery C Reference.