On Sat, 16 Apr 2005, Mike Schmidt wrote:
Now I have an additional quick question, more a design question than anything else: if I understand correctly, I should have 1 mailstream open to an imap server, not one per mailbox. I should reuse this mailstream when switching mailboxes instead of making a new one, is that correct? What happens to the message cache in this case?

It's a bit more complicated than that.

You should have one MAILSTREAM open for each mailbox which you want to be open *simultaneously*.

If you want to "switch" from one open mailbox to another, it is better to reuse the mailstream than to close the existing mailstream and open a new mailstream on the new name.

With any of these operations, there are certain costs:

Opening a new connection has the cost of TCP/IP session initiation, encryption negotiation, and authentication negotiation.

Selecting a mailbox has the cost of server overhead to load/process the mailbox, and the protocol overload of loading the client cache.

Closing a mailstream has the cost of discarding the message cache for the old name and closing the TCP/IP session.

Opening a new mailstream has both the "opening a new connection" and the "selecting a mailbox" cost.

Recycling a mailstream has the cost of discarding the message cache for the old name and "selecting a mailbox", but avoids the costs of closing the TCP/IP session and "opening a new connection".

Keeping multiple sessions open allows you to monitor multiple mailboxes simultaneously, but there is a practical limit of how many mailboxes that you should have open at a time, no more than a handful. You want to do this if you want immediate real-time access to the mailbox and its messages, as opposed to passive monitoring.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.

Reply via email to