Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ library for Asynchronous HTTP Client

I am looking for a C++ library to send an asynchronous HTTP request such that main thread is not blocked and notified later once http url request is done.

Please advise if there as such any C++ library to achieve this asynchronous HTTP client feature.

like image 242
user1908860 Avatar asked Nov 04 '22 07:11

user1908860


1 Answers

libcurl's "multi" interface can run HTTP requests in the background (it uses a 2nd thread, but the effect is the same). First, create a multi handle with curl_multi_init. Then, set up an easy handle (create it with curl_easy_init and set the URL and other options with curl_easy_setopt) and call curl_multi_add_handle. curl_multi_perform will start the transfer(s) and return immediately, and you can call curl_multi_info_read to get the status of your easy handles. Don't forget to call curl_multi_cleanup when you're done.

http://curl.haxx.se/libcurl/c/libcurl-multi.html

like image 128
br1ckd Avatar answered Nov 11 '22 02:11

br1ckd