🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
5 messages
5 total messages Started by Paw Suddergaard Mon, 25 Sep 2006 14:54
TidSMTP-> Abort?
#1890
Author: Paw Suddergaard
Date: Mon, 25 Sep 2006 14:54
32 lines
1556 bytes
Hi All,

I'm having some troubles aborting a TidSMTP component after i've called 
send.

My current setup:

I call:
TidThread->Start();

Then:

void __fastcall TEasyMail::IdThreadComponent1Run(
       TIdCustomThreadComponent *Sender)
{
  IdSMTP->Send(IdMessage);
}
//---------------------------------------------------------------------------

I have an abort button that calls terminate:

void __fastcall TEasyMail::IdThreadComponent1Terminate(
       TIdCustomThreadComponent *Sender)
{
  // Does nothing:  IdSMTP->Socket->Close();
  // Does nothing: IdSMTP->Disconnect();
}
//---------------------------------------------------------------------------

Any ideas?

thanks
Re: TidSMTP-> Abort?
#1891
Author: Remy Lebeau (TeamB)
Date: Mon, 25 Sep 2006 16:56
11 lines
1155 bytes
"Paw Suddergaard" <paw@top-house.dk> wrote in message
news:4517ed96$1@newsgroups.borland.com...

> I'm having some troubles aborting a TidSMTP component after
> i've called send.

Which version of Indy are you actually using?


Gambit
Re: TidSMTP-> Abort?
#1899
Author: Paw Suddergaard
Date: Tue, 26 Sep 2006 08:06
3 lines
1042 bytes
Sorry i forgot to tell you. I'm using Indy 9 on c++ Builder 6 Pro.

thanks!
Re: TidSMTP-> Abort?
#1900
Author: Remy Lebeau (TeamB)
Date: Tue, 26 Sep 2006 09:15
29 lines
2042 bytes
"Paw Suddergaard" <paw@top-house.dk> wrote in message
news:4517ed96$1@newsgroups.borland.com...

> I have an abort button that calls terminate:
>
> void __fastcall TEasyMail::IdThreadComponent1Terminate(
>        TIdCustomThreadComponent *Sender)
> {
>   // Does nothing:  IdSMTP->Socket->Close();
>   // Does nothing: IdSMTP->Disconnect();
> }

That is the completely wrong place to put that code.  The thread is blocked
while Send() is running.  The OnTerminate event is triggered when the thread
is terminated (thus its name).  Calling Terminate() DOES NOT actually
terminate the thread immediately.  All it does is sets the Terminated
property to true and nothing else.  That signals to the thread that it
should terminate itself at its earliest convenience, which it can't do until
after Send() returns.

You need to call Disconnect() inside your button OnClick event directly, not
in the thread's OnTerminate event, in order to abort the sending.  You
should also use DisconnectSocket() instead of Disconnect(), since you are
closing the connecting from a different thread than the one that established
the connection.


Gambit
Re: TidSMTP-> Abort?
#1901
Author: Paw Suddergaard
Date: Tue, 26 Sep 2006 10:37
3 lines
1009 bytes
Thanks Remy, that worked perfectly :O)

/Paw
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads