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?
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.