Twenty requests in flight at once on a single thread.
Twenty requests in flight at once on a single thread.
#include <asio.hpp>
#include <iostream>
#include <string>
int main() {
asio::io_context io;
int done = 0;
for (int i = 1; i <= 20; ++i) {
"https://postman-echo.com/get?n=" + std::to_string(i),
std::cout << "#" << i << " -> "
<< (ec ? ec.message() : std::to_string(res.
http_code_))
<< "\n";
++done;
});
}
io.run();
std::cout << done << " requests completed\n";
}
auto async_get(std::string url, CompletionToken &&token)
Definition cofetch.h:324
long http_code_
Definition cofetch.h:176