iPhone/iPod Touch/iPad 应用程序中与服务器机制的通信

发布于 2024-09-30 00:45:51 字数 371 浏览 1 评论 0原文

想象一个需要使用 WiFi 或 3G 网络在移动设备(iPhone、iPad、iPod Touch)之间来回传递消息的应用程序。这些消息不是直接在设备之间传递,而是通过管理该应用程序的服务器。

每个移动设备都需要能够向服务器发起“消息”并 服务器需要向客户端发送消息(理想情况下,客户端无需不断轮询)。

UDP 是否可以双向使用以在服务器和移动设备之间传递消息?服务器有一个已知的 IP,但是 3G 网络上的设备呢? 路由器后面的 Wifi 设备怎么样?可能无法联系到他们。

鉴于此,是否别无选择,只能设计一种解决方案,让客户端移动设备“轮询”服务器以获取其消息消息,而不是服务器发起与它们的通信会话来传递待处理的消息?

关于该问题的任何模式或讨论我可以受益?

Imaging an application that needs to have messages to back and forth between mobile devices (iPhone, iPad, iPod Touch) using either WiFi or 3G Networks. The messages are not directly between devices, but rather go through a sever that manages this application.

Each mobile device needs the ability to initiate a "message" to the server and
servers need to send messages to clients (ideally, without clients having to poll constantly).

Can UDP be used bi-directionally for the purpose of passing messages around between servers the mobile devices? the server has a known IP, but what about devices on 3G networks?
what about devices in Wifi behind a router? it may be impossible to reach them.

In light of that, is there no choice but to design a solution in which client mobile devices "poll" the server for their messages messages rather than the server initiating a communication session with them to pass pending msgs?

Any patterns or discussions on that issue I can benefit from?

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

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

发布评论

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

评论(1

你是年少的欢喜 2024-10-07 00:45:51

我推荐基于 HTTP 的轮询方法。如果没有其他原因,您可以借鉴大量现有代码和经验。 iPhone 是一种非常面向网络的设备,HTTP 客户端工作相对简单快捷。轮询更新应该非常简单,我认为,除了最实时的通信需求之外,这足以满足所有需求。

I'd recommend an HTTP-based polling approach. If for no other reason, there's lots of existing code and experience you can draw from. The iPhone is a very web-oriented device and HTTP client work is relatively easy and quick. Polling for updates should be quite simple and, I would think, would suffice for all but the most realtime communication needs.

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