I am using libcurl to connect to a LightStreamer server. Consider the following minimal example:
#include <curl/curl.h>
static size_t writeCallback(char *ptr, size_t size, size_t nmemb, void* userdata)
{
printf("%.*s\n", size * nmemb, ptr);
return size * nmemb;
}
int main() {
const char url[] =
"http://push.lightstreamer.com/lightstreamer/create_session.txt?LS_protocol=TLCP-2.0.0";
const char data[] =
"LS_adapter_set=DEMO&LS_cid=mgQkwtwdysogQz2BJ4Ji%20kOj2Bg";
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback);
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, sizeof(data));
curl_easy_perform(curl);
return 0;
}
When running this, the server never closes the connection; this means that curl_easy_perform never returns.
However, I need to transmit data on the same connection to the server, e.g. to subscribe to data items. But from my understanding from the curl documentation I should not call curl_easy_perform a second time while the first perform is still running.
How could this be achieved? I looked into the documentation for the multi interface, but I am not sure if this is what I need.