0

How can I send multiple post requests using TIdHTTP at the same time?

lHTTP1.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);
lHTTP2.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);
lHTTP3.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);

I tried using three threads to do that, but there is a one second delay between every post message.

How can I send all the post messages in the same second?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
RepeatUntil
  • 2,272
  • 4
  • 32
  • 57
  • Doing this in 3 simultaneous threads doesn't automagically make all 3 work at the same time. There are other factors, such as network traffic, and cpu / hard disk speed and many more. – Jerry Dodge Mar 03 '15 at 00:43

1 Answers1

2

Since TIdHTTP is a blocking component, using separate threads is the correct approach. The 1s delay on each post could be related to how the OS schedules threads, or it might be related to network delays, or you might be using a version of Indy that has internal delays (for instance, if an HTTP server sends a 3xx response to a POST request, TIdHTTP waits up to 5s to make sure the server sends a proper response body - some buggy servers do not). It is difficult to know where your 1s delay is actually occurring. You will have to debug/profile your project to find out, we can't do that for you.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770