Created
May 27, 2019 15:48
-
-
Save TvdW/bea189b3926993fff584471457350d1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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