1

I am using the libcurl4-openssl-dev library on my ubuntu 12.04 LTS box hosted as a virtual machine. I am making a simple POST request to a particular URL, and observed that it is far too slow compared to WinInet.

After analysing the scenario with wireshark traffic analyzer, I found out that the actual connection with the server was being made after a considerable idle time, and this was the biggest contributor to the total time. My code is as below:

curl_global_init(CURL_GLOBAL_ALL);
this->m_curl = curl_easy_init();
curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 40);
.....
curl_easy_setopt(m_curl, CURLOPT_URL, cptrInputUrl);//URL
curl_easy_setopt(m_curl, CURLOPT_POST, 1);//POST
curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, cptrPostInput);//POST FIELDS
curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, &writeCallback);//WRITE DATA TO
curl_easy_setopt(m_curl,CURLOPT_TCP_NODELAY, 1);

WriteLog("Downloading..");
res = curl_easy_perform(m_curl);//CARRY OUT OPERATION
WriteLog("Completed download..");

The WriteLog function prefixes the current time with the log. I see that the system remains idle for atleast 5-10 seconds before initiating connection with the given server.

I am wondering if I am missing some curl option here. Please help.

user1872325
  • 71
  • 1
  • 9

0 Answers0