[EMAIL PROTECTED] wrote:

> as you see, the pop component is not connected when i do the connect
> cmd. that's the strange thing, the connection is closed but the
> component is not in a ready state.

Sorry, now I recall that there is a BUG in the component since a long
time!! I fighted for getting this fixed, however the bug is still present.
 
What happens in your case is that GMX doesn't send a response to the
QUIT command but closes the connection at once. 

The bug is the "Special processing for Quit" below, comment that out
and rebuild all. 

procedure TCustomPop3Cli.TriggerRequestDone(Error: Word);
begin
==> (*  
    { Special processing for Quit (Roger Morton 24-12-99) }
    if FRequestType = pop3Quit then begin
        if FWaitingOnQuit then
            { When the second RqDone arrives (from WSocketSessionClosed),   }
            { treat it as a normal event by setting a zero Error code       }
            Error := 0
        else begin
            { When the first RqDone arrives, set the FWaitingOnQuit flag so }
            { we're ready to handle a second RqDone.                        }
            { Take no other action (in particular, we don't advise the user }
            { that the first RqDone has happened)                           }
            FWaitingOnQuit := True;
            Exit;
        end;
        { Fall down here for all normal RqDone, and after the second RqDone }
        { following a Quit                                                  }
        FWaitingOnQuit := False;
    end;
==> *)

This code prevents that RequestDone fires in case the server doesn't
send a response on the Quit command, and thus the Pop3State is never reset
properly.  

After you outcommented this code try the little test program below, don't
run it w/o a break point since it would reconnect in a loop infinitely.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Pop3Prot, StdCtrls;

const
  WM_RECONNECT = WM_USER + 1;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Pop3Cli1: TPop3Cli;
    procedure Pop3Cli1RequestDone(Sender: TObject; RqType: TPop3Request;
      Error: Word);
    procedure Button1Click(Sender: TObject);
  protected
    procedure WmReconnect(var Msg: TMessage); Message WM_RECONNECT;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    Pop3Cli1.Connect;
end;

procedure TForm1.WmReconnect(var Msg: TMessage);
begin
    Pop3Cli1.Connect;
end;

procedure TForm1.Pop3Cli1RequestDone(Sender: TObject; RqType: TPop3Request;
  Error: Word);
begin
    case RqType of
        pop3Connect : 
            if (Error = 0) then
                TPop3Cli(Sender).Quit;

        pop3Quit :
            begin
                { Regardless of Error or not Error }
                if TPop3Cli(Sender).Connected then
                    TPop3Cli(Sender).Abort // No problem here since the server 
sent the response
                else // Post a custom message if you want to reconnect
                    PostMessage(Handle, WM_RECONNECT, 0, 0);
            end;
    end;
end;

end.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html




> 
> 
> 
> AG> [EMAIL PROTECTED] wrote:
>>> procedure TMailAlert.Pop3ClientRequestDone;
>>> begin
>>>   if (FPop.connected) and (CheckError) then begin
>>>     FPop.quit;
>>>     exit;
>>>   end;
>>> 
>>> ...
>>> 
>>> what could be the cause that the component is not ready after the
>>> error ?
> 
> AG> After sending command Quit you should receive a server response.
> AG> When it's received you may either close or abort the connection
> AG> yourself or wait until the server drops the connection.
> AG> Anyway start next connection attempt only when you are not
> connected, 
> AG> means after SessionClosed fired.
> 
> AG> --
> AG> Arno Garrels
> 
> 
> 
> 
> --
> Mit freundlichen Grüßen
> [EMAIL PROTECTED]
> mailto:[EMAIL PROTECTED]
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to