IMAP IDLE exists since 1997 (RFC2177) and works decent enough for single mailboxes.
It is limited to only a single mailbox however, which is not quite ideal if one does server-side filtering (as one then needs N connections for N folders).
But for that there is IMAP NOTIFY (RFC5465) since 2009, which covers all remaining use cases..