Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to abort TIdImap4.Connect?
(11-15-2018, 04:36 AM)edwinyzh Wrote: I just browsed the Indy source code, it seems that the uninterruptible time range is in between OnStatus(hsConnecting) and OnStatus(hsConnected), where you have no way to abort until the timeout's reached?

That is not true. As I already explained in my previous reply, that time range IS interruptible. You just need to close the underlying socket itself to do so.

Between hsConnecting and hsConnected is when Indy is making the actual connection to the server (and is the only time when ConnectTimeout takes effect). If the socket is closed before the underlying socket API connect() is called, the connection fails with an "invalid socket" error. If the socket API connect() is already in progress when the socket is closed, the connection gets aborted with an appropriate error. Either way, the end result is the same - the API connect() fails, the connecting thread gets terminated, and TIdTCPClient.Connect() sees that and raises an exception into your code (typically EIdSocketError or EIdConnectException).

The only time range that IS NOT interruptible is between hsResolving and hsConnecting, when Connect() is blocked on the OS performing a DNS lookup, and ConnectTimeout has no effect.


Messages In This Thread
How to abort TIdImap4.Connect? - by edwinyzh - 11-14-2018, 05:56 AM
RE: How to abort TIdImap4.Connect? - by rlebeau - 11-14-2018, 07:55 PM
RE: How to abort TIdImap4.Connect? - by edwinyzh - 11-15-2018, 04:36 AM
RE: How to abort TIdImap4.Connect? - by rlebeau - 11-15-2018, 05:15 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)