🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #466

Hang issue with

#466
From: BrianV
Date: Sat, 23 Feb 2008 03:51
97 lines
4371 bytes
I'm having lots of trouble getting Indy SMTP to work reliably for me.  I am 
using 10.1.5, the version that ships with C++ Builder 2007.  One of the 
issues I'm having is the following:

When calling Connect() on a IdSMTP component, the flow goes through Indy 
code like this:

/*------------------------------------------------------------*/
//   First, IdSMTP line 416
/*------------------------------------------------------------*/
procedure TIdSMTP.Connect;
begin
  inherited Connect; try
    GetResponse(220);
    SendGreeting;
  except
    Disconnect;
    Raise;
  end;
end;

/*------------------------------------------------------------*/
// Then here...
/*------------------------------------------------------------*/
function TIdTCPConnection.GetResponse(AAllowedResponse: SmallInt): SmallInt;
begin
  Result := GetResponse([AAllowedResponse]);
end;

/*------------------------------------------------------------*/
Then to IdTCPConnection line 547
/*------------------------------------------------------------*/
function TIdTCPConnection.GetResponse(
 const AAllowedResponses: array of SmallInt): SmallInt;
begin
  GetInternalResponse;
  Result := CheckResponse(LastCmdResult.NumericCode, AAllowedResponses);
end;

/*------------------------------------------------------------*/
Then to IdTCPConnection line 674
/*------------------------------------------------------------*/
procedure TIdTCPConnection.GetInternalResponse;
var
  LLine: string;
  LResponse: TIdStringList;
begin
  CheckConnected;
  LResponse := TIdStringList.Create; try
    // Some servers with bugs send blank lines before reply. Dont remember 
which
    // ones, but I do remember we changed this for a reason
    LLine := IOHandler.ReadLnWait;
    LResponse.Add(LLine);
    while not FLastCmdResult.IsEndMarker(LLine) do begin
      LLine := IOHandler.ReadLn;
      LResponse.Add(LLine);
    end;
    //Note that FormattedReply uses an assign in it's property set method.
    FLastCmdResult.FormattedReply := LResponse;
  finally Sys.FreeAndNil(LResponse); end;
end;

/*------------------------------------------------------------*/
and finally to IdIOHandler line 1199
/*------------------------------------------------------------*/
function TIdIOHandler.ReadLnWait(AFailCount: Integer = MaxInt): string;
var
  LAttempts: Integer;
begin
// MtW: this is mostly used when empty lines could be send.
  Result := '';
  LAttempts := 0;
  while (Length(Result) = 0) and (LAttempts < AFailCount) do begin
    Inc(LAttempts);
    Result := Sys.Trim(ReadLn);
  end;
end;

The neat thing about this last method, is that no matter what you set 
timeouts to, this last method is called without a value for AFailCount, and 
so it loops through MaxInt times.  So if a user ever enters an incorrect 
port for their SMTP connection, there doesn't seem to be any straightforward 
way to avoid an interminable timeout where the app just hangs.

I know this would be an easy fix in Indy, but the problem is that I've only 
spent a little time trying to make Indy work for me, and have hit a few 
pretty major issues like this that seem to be complete show stoppers for 
trying to use this in a commercial app.

Are there other SMTP components out there that are less buggy (but still 
work with SSL), or do I need to give Indy more of a chance?  A lot of the 
stuff Indy does is very impressive, but I have to say, so far it has been 
EXTREMELY frustrating.

Thanks for any advice,
Brian
Technical Details
Message-ID: <47bf9844$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ea302164fdd76b72,start
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "BrianV" <bvanmatre_remove_@yahoo.com>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Hang issue with 
Date: Fri, 22 Feb 2008 20:51:32 -0700
Lines: 100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 24.9.114.34
Message-ID: <47bf9844$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1203738692 24.9.114.34 (22 Feb 2008 19:51:32 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail