Skip to content

Instantly share code, notes, and snippets.

@TvdW
Created May 27, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TvdW/bea189b3926993fff584471457350d1d to your computer and use it in GitHub Desktop.
Save TvdW/bea189b3926993fff584471457350d1d to your computer and use it in GitHub Desktop.
#include "curl/curl.h"
int main(int argc, char** argv)
{
CURLM *multi = curl_multi_init();
curl_multi_setopt(multi, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
curl_multi_setopt(multi, CURLMOPT_MAX_HOST_CONNECTIONS, 4);
int j;
for (j = 0; j < 100; j++) {
int i;
CURL *easies[10];
for (i = 0; i < 10; i++) {
CURL *easy = curl_easy_init();
easies[i] = easy;
if (i % 2 == 0)
curl_easy_setopt(easy, CURLOPT_URL, "http://tvdw.eu");
else
curl_easy_setopt(easy, CURLOPT_URL, "https://home.xifon.eu");
curl_easy_setopt(easy, CURLOPT_VERBOSE, 1);
// PROXY: Likely not relevant but my environment requires that I use one.
curl_easy_setopt(easy, CURLOPT_NOPROXY, "");
curl_easy_setopt(easy, CURLOPT_PROXY, "http://my-proxy-host:3128");
curl_multi_add_handle(multi, easy);
}
int running= 1;
while (running) {
int numfds;
curl_multi_perform(multi, &running);
curl_multi_wait(multi, NULL, 0, 1000, &numfds);
}
for (i = 0; i < 10; i++) {
curl_multi_remove_handle(multi, easies[i]);
curl_easy_cleanup(easies[i]);
}
}
curl_multi_cleanup(multi);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment