I need to connect to multiple sites (variable number of sites, may be over 100) and fetch some data in a loop for each site.

I create a thread and a QNAM for each site. (For each site QNAM must have different cookies).

All good for few sites, but when sites number is big I get

"Too many open pipes"

and crash.

Then I've tried using a single thread but is too slow because it won't fetch data from next site until current site reply is finished.

There is some way to limit the number of simultaneous connection to 15 - 20 while the others waiting, and when there is a free slot open connection, do stuff and close connection so that the other threads can do their job ?