Tidhttp.connectTimeout not working!

So, I use tidhttp to create mail requests. when I try to set connectTimeout at any period of time, it does not affect. I am still waiting ~ 5 seconds before I get an exception. Thanks in advance!

+3
source share
1 answer

If you connect to the host name instead of the IP address, the host name must be resolved to the IP address through DNS lookup, which can take some time, especially if the host name has not yet been cached by the OS. The ConnectTimeout property is not taken into account during this time.

In addition, when ConnectTimeout is non-zero or TIdAntiFreeze is used, Indy must use the internal workflow to make the actual connect API () call to the server. Starting a new thread may take some time, depending on the available system resources at this point. ConnectTimeout does not take this time into account.

The current implementation of ConnectTimeout applies only to the connect API call connect () itself, and not to any additional work necessary to reach this point. Thus, if you have a 5 second ConnectTimeout value set, it may have been more than 5 seconds before TIdTCPClient.Connect () exits.

+7
source

Source: https://habr.com/ru/post/1776780/


All Articles