C ++ library for asynchronous HTTP client

I am looking for a C ++ library to send an asynchronous HTTP request so that the main thread is not blocked and is notified later as soon as the HTTP request is completed.

Please advise if there is such a C ++ library to achieve this asynchronous HTTP client function.

+4
source share
2 answers

The libcurl "multi" interface can run HTTP requests in the background (it uses a second thread, but the effect is the same). First create a multiroom with curl_multi_init . Then set up a simple handle (create it with curl_easy_init and set the URL and other parameters with curl_easy_setopt ) and call curl_multi_add_handle . curl_multi_perform will start the transfer (transfer) and return immediately, and you can call curl_multi_info_read to get the status of your simple pens. Remember to call curl_multi_cleanup when done.

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

+1
source

The library should not be asynchronous. While this is thread safe, you should do everything you need to do in a separate thread, and use the thread primitives to synchronize later with the main thread.

0
source

All Articles