4 Replies Latest reply: Jan 20, 2011 12:21 PM by roaminggnome
MobileDev Level 3 Level 3 (565 points)
I've seen quite a few postings here where otherwise smart people claim that the "Push" mail/etc synchronization used by the iPhone never transmits any data until there is something to send. Here are the facts:

*BOTH Fetch and Push ping the server.*

+Sometimes Push will even ping more often.+ Fetch always pings at a certain interval that you set. Push's interval is dynamic and changes depending on network TCP/IP connection longevity. It can vary from every few minutes to well over half an hour.

*The main difference is in how quickly the server responds.*

Fetch = Phone sends request. Server replies immediately. Wait a while. Repeat.

Push = Phone sends request with a timeout. Server replies immediately, OR when mail arrives, OR just before the timeout. Repeat.

*I'm confused. Why does Push have to ping at all? Doesn't it just magically send some kind of notification to the phone?*

Sorry, no magic in this case. The server must know your IP address to respond to, and the phone must be waiting for that response.

Mobile IP connections are volatile. Your IP address can change. The connection will be dropped by the carrier if they don't see traffic. The connection can be dropped if a firewall along the network path has a smaller timeout. If you're on EDGE and you answer a phone call, the data connection stops working as well.

Anything that interrupts the connection, means the server can't respond with a notification.

So the Push agent on the phone creates a connection and then pings over it as often as need to keep the connection alive. Push figures out the correct ping interval by whether or not it hears from the server within the last timeout period that it used.

To use an analogy: Fetch is like calling a friend every 15 minutes to see if there's any news. Push is like calling your friend, then putting them on speakerphone and waiting for them to speak. (That way, you get the news immediately.) But if they never reply, the connection automatically drops. So every once in a while you call out "Are you still there?"

Touchscreen laptop and industrial handhelds, Other OS