Menu

#7 Code hangs because of no timeout on sending commands

open
nobody
None
5
2006-12-15
2006-12-15
Anonymous
No

In SmtpProxy.Open(), besides this.ReceiveTimeout also this.SendTimeout must be set.

Otherwise there is no timeout when sending data TO the SMTP server

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I believe this is resolved by moving the LoopTimeout declaration outside of the do/while loop in the SmtpProxy.ReadResponse() method.

    Original code:

    ...
    int count = 0;
    // read until last response has been received
    // (indicated by whitespace after the numerical response code)

    do
    {
    int LoopTimeout = 0;
    if (stream.DataAvailable)
    {
    count = stream.Read(serverbuff, 0, serverbuff.Length);
    response = String.Concat(response, enc.GetString(serverbuff, 0, count));
    }
    ...
    ============================================

    Modified code:

    ...
    int count = 0;
    int LoopTimeout = 0;
    // read until last response has been received
    // (indicated by whitespace after the numerical response code)

    do
    {
    if (stream.DataAvailable)
    {
    count = stream.Read(serverbuff, 0, serverbuff.Length);
    response = String.Concat(response, enc.GetString(serverbuff, 0, count));
    }
    ...
    ============================================

     
  • Nobody/Anonymous

    Logged In: NO

    Solution proposed by Nobody is correct, but also the other change must be done
    (In SmtpProxy.Open(), besides this.ReceiveTimeout also this.SendTimeout must be set.)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.