My development organization has its own wrapper implementation for threads and select(). The application needs to be enhanced to perform HTTPS requests, and I've decided to use libcurl. After some research, I see that the curl_easy_perform is a blocking call, so I've decided to use the curl_multi_perform approach for non-blocking calls to allow other work in the threads.
The HTTPS request will need to be performed periodically to the same URL. I know I can keep the same curl_easy handle and give that to the curl_multi handle. I would perform the curl_multi_perform to get the results, but I would later need to use curl_multi_perform to resend the request, say in 5 minutes. So, this would be a consecutive request using the same easy handle. However, I'm not sure how the curl_easy interface tells the multi interface as to when to resend the request after I have received results from the first request. How do I accomplish this?
(Maybe drop the easy handle from the multi handle, and re-add it to the multi handle when a request is needed again?)
I presume that whatever technique is used, that the outgoing request will be using the same outgoing port.
(Maybe drop the easy handle from the multi handle, and re-add it to the multi handle when a request is needed again?)
Correct. From the libcurl documentation:
When a single transfer is completed, the easy handle is still left added to the multi stack. You need to first remove the easy handle with curl_multi_remove_handle and then close it with curl_easy_cleanup, or possibly set new options to it and add it again with curl_multi_add_handle to start another transfer.
.
I presume that whatever technique is used, that the outgoing request will be using the same outgoing port
This is not guaranteed. libcurl will attempt to re-use existing connections that are associated with the easy handle, but if the previous connection has already died then a new connection with an unpredictable local port will be established.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With