Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:03:05+00:00 2026-05-24T14:03:05+00:00

After experimenting with many IMAP API’s, I have decided to write my own (Most

  • 0

After experimenting with many IMAP API’s, I have decided to write my own (Most are memory hogs, some just do not work, out of memory exception etc etc etc).

Anyway I have wrote some code that works (using TCPClient object) and its good so far. However, I want my one to be able to handle multiple requests to the mail server. For example:
Say I get a list of all the UIDs, then I cycle through this list getting what I want (Body, Header, etc) for each message.

The question is, how would I handle, multiple requests at the same time? So instead of looping through the UIDs one at a time I can instead process 10 at a time.

What would be the best approach here? An array of TCP Clients, each with its own thread?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:03:06+00:00Added an answer on May 24, 2026 at 2:03 pm

    In general it’s recommended that IMAP clients only have at most one connection to the server at all times. Not only does additional connections require valuable resources on the server but more important the IMAP specification does not guarantee that two connections can select the same mailbox at the same time. Relying on this capability being present on the server may render your client incompatible with those servers.

    Instead you should use the protocol as efficient as possible. Note that many commands can operate on a set or range of UIDs. This allows you to make one singe request where you specify every UID instead of making one request for each UID separately.

    Another good practice is to not request more data than what is currently needed. For example say that you have a list of messages. Then don’t request detailed information for all of them, only request information for the messages that are currently visible.

    I highly recommend that you read RFC 2683, IMAP4 Implementation Recommendations. It covers this among other things.

    If you decide to use multiple connections anyway then a good approach is usually to use asynchronous operations and not use individual threads explicitly. Combination with some kind of run loop integration is often useful as well, that way your code is called when there is data to read instead of you code having to poll or explicitly check for it. This is often a good approach even if you’re only using a single connection. Keep in mind that according to the IMAP protocol the server may send you responses even when you have not explicitly asked for them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After doing some research on the subject, I've been experimenting a lot with patterns
After experiencing some performances issues on my client side, we decided to give a
After experimenting with some triangulation work I ran across the question on how to
After being stumped by an earlier quesiton: SO google-analytics-domain-data-without-filtering I've been experimenting with a
After deploying WCF server (svc) on my Server, I have got this message when
After some time researching and trying different things I still cannot get my @ExceptionHandler
After a long search I'm still confused about it although I found some related
gcc 4.4.4 c89 I was just experimenting with a int array. And something just
Ok after experimenting a little bit I found out that resin was calling my
First of all, I'm using Rails 3.1.1 and Ruby 1.9.3-p0 . After experimenting for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.