title: cURL - multi - too much open sockets
body: <p>I have problem with cURL. I have used <code>curl_multi</code> with enabled pipelining (server support it). But I have over 10000 single URLs, I need to download. I dont have that many free sockets. How to handle this ?</p>
  
  <p>I have read about  <code>curl_multi_socket_action</code>, but I can not find some simple example, or how to modify my code</p>
  
  <pre><code>CURLM * curlm = curl_multi_init();
  
  curl_multi_setopt(curlm, CURLMOPT_MAXCONNECTS, 3);
  curl_multi_setopt(curlm, CURLMOPT_PIPELINING, 1);
  
  std::vector&lt;CURL_WRITE *&gt; ptrArray;
  
  std::map&lt;MyStringAnsi, MyStringAnsi&gt;::const_iterator it;
  for (it = data[0].begin(); it != data[0].end(); it++)
  {
      CURL_WRITE * curlData = new CURL_WRITE;
      curlData-&gt;dataIndex = &amp;(it-&gt;first);
      curlData-&gt;threadID = 0;
  
  
      CURL * curl = InitSingleCURL(it-&gt;first, curlData);          
      curl_multi_add_handle(curlm, curl);
  
      ptrArray.push_back(curlData);
      curls.push_back(curl);
  }
  
  
  int still_running = 0;
  /* lets start the fetch */
  do 
  {
  
      while(curl_multi_perform(curlm, &amp;still_running) == CURLM_CALL_MULTI_PERFORM);
      #ifdef _WIN32
       Sleep(10);
      #else
       usleep(10);
      #endif
   } while (still_running);
  </code></pre>