iPhone模拟器-连接到主机

发布于 2024-12-23 02:36:39 字数 290 浏览 3 评论 0原文

我正在开发一个 iPhone 应用程序,该应用程序(完成后)可以通过互联网与后端服务器进行通信。当我进行开发时,我经常处于没有互联网连接的情况(阅读“长途飞行”)。我的本地 Mac 上运行着一个 Web 服务器,其中包含实时网站的完整副本。理论上,我应该能够从 iphone 模拟器连接到主机上运行的 Web 服务器 - 但如何呢?请注意,我没有外部连接,因此所有 mac IP 接口都处于“断开连接”状态(此外,它们被关闭 - 节省电池)。

我需要使用模拟器的哪些地址?主机 mac 和 sim 之间是否有某种桥接接口?

非常感谢。

I am working on an iphone app that would (when completed) communicated with a back-end server over the internet. While I'm doing the development, I'm often in a situation with no internet connection (read 'long flights'). I have a web server running on my local mac, which has a full copy of the live web site. Theoretically, I should be able to connect from the iphone simulator to a web server running on the host machine - but how? Note that I don't have an external connection, therefore all of the mac IP interfaces are in the "disconnected" state (moreover, they are turned off - saves the battery).

What addresses would I need to use from the simulator? Is there some sort of a bridge interface between the host mac and the sim?

Many thanks.

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

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

发布评论

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

评论(1

ζ澈沫 2024-12-30 02:36:39

如果您在模拟器中运行,请连接到 127.0.0.1——这是您本地计算机的地址(也称为环回地址)。即使您的正常网络接口关闭或禁用,它也会被正确配置和路由。但请注意,由于此地址始终是本地计算机,因此如果您在设备上运行应用程序,则这将不起作用(因为设备将尝试连接到自身,并且不会运行您的服务器实例)。

If you're running in the simulator, connect to 127.0.0.1 -- that is the address of your local machine (also known as the loopback address). It will be configured and routed properly even if your normal network interfaces are down or disabled. Please note, however, that since this address is always the local machine, this will not work if you are running the app on a device (as the device will attempt to connect to itself and it will have no instance of your server running).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文