Setting up my iPhone and various other clients to access my email via IMAP (Internet Message Access Protocol) I’d been reading about how Google finally supported the “IDLE” command and how this made “push” work a lot better. I finally got around to looking up some details. In a nutshell, the client keeps the TCP connection open; sends the “IDLE” command; and eventually the server responds when there’s a message.

From IMAP IDLE: The best approach for ‘push’ email:

How IDLE Works

IMAP works by the software on the mobile device (the client) issuing commands to the server. An IMAP server provides two things in response to a client command:

  1. An answer to the request.
  2. Information on any new messages.

This means that where a client is actively doing things with an IMAP server, it will > be told immediately about new messages. The client can then get summary information on the message to present to the user, and can (automatically) download the message when appropriate.

This means that an active client will always be kept up to date. The IDLE command deals with the situation where the client has no more requests to make. The server responds to the idle command when there is a new message (or messages) which indicates to the client that there are new messages.