Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can you interrupt an Indy connect call?

I have a connect that I give 20 seconds to for a timeout (slow link). I need to allow my user to cancel this connect call.

I already have the connect occurring in a thread so that I can keep the GUI going, but how do I tell Indy to cancel? I also have to call cancel from the main thread because the connect call is blocked. Is this possible?

This is for C++ Builder, but a Delphi answer will do just fine.

like image 502
Gregor Brandt Avatar asked Dec 01 '25 20:12

Gregor Brandt


1 Answers

The only way to abort Connect() is to call Disconnect() from a different thread context than the one that is calling Connect(). In this situation, your main thread can call Disconnect() directly, and then your thread can handle the exception that Connect() raises in reply.

like image 173
Remy Lebeau Avatar answered Dec 04 '25 23:12

Remy Lebeau