Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Mar : Re: TIdSSLIOHandlerSocketOpenSSL access violation

www.cryer.info
Managed Newsgroup Archive

Re: TIdSSLIOHandlerSocketOpenSSL access violation

Subject:Re: TIdSSLIOHandlerSocketOpenSSL access violation
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Wed, 19 Mar 2008 11:36:16

"Hans de Vries" <hans401idonotwantspam@yahoo.com> wrote in message
news:ani2u3178evto938at7ssq5q5svafsokhq@4ax.com...

> shouldn't I free the TIdSSLIOHandlerSocketOpenSSL object
> assigned to the IOHandler?

The code I gave you earlier has the TIdMySmtp set as the Owner for it.  It
will be destroyed when the TIdMySmtp is destroyed.

> Anyway, I did this in the Disconnect method. The code looks
> like this right now:

I would suggest an alternative approach - create the IOHandler object during
TIdMySmtp's construction, assign it to the IOHandler property in Connect()
(in case the user tries to change it), and free it in the destructor (or let
TComponent handle that internally).  No need to override Disconnect at all
(which you are not doing correctly anyway).  For example:

    TIdMySmtp = class(TIdTCPClient)
    private
        fIO: TIdSSLIOHandlerSocketOpenSSL;
        //...
    protected
        procedure InitComponent; override;
    public
        procedure Connect; override;
        //...
    end;

    procedure TIdMySmtp.InitComponent;
    begin
        inherited InitComponent;
        fIO := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
        with fIO do
        begin
            TransparentProxy := TIdSocksInfo.Create(fIO);
            with TIdSocksInfo(TransparentProxy) do
            begin
                Socks.Version := svSocks4A;
                Socks.Host := '127.0.0.1';
                Socks.Port := 9050;
            end;
            ReadTimeout := 300000; // 5 minutes
        end;
    end;

    procedure TIdMySmtp.Connect;
    var
        Answer: string;
    begin
        with fIO do
        begin
            with TIdSocksInfo(TransparentProxy) do
            begin
                // update SOCKS as needed...
            end;
            // Update IO as needed...
        end;

        IOHandler := fIO;
        inherited Connect;

        //...
    end;


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive