cURL / Mailing Lists / curl-library / Single Mail


simple chat example without using curl_easy_send and curl_easy_recv

From: swathi upadhyaya <>
Date: Mon, 30 May 2011 12:15:15 +0530


I want to write chat example using libcurl.

Connect to server
Send a message to server
Read message from server

I tried sendrecv example from [ as in]

This example uses curl_easy_send and curl_easy_recv on raw socket.
I would like to use CURLOPT_POST to send and CURLOPT_WRITEFUNCTION to recv data.

But this is not working. It always fetches the home page of server.
Tried CURLOPT_NOBODY then recv buffer will be 0 bytes

Here is example code
const char *request = "GET /index1.html HTTP/1.1\r\nHost:\r\n\r\n";
curl_easy_setopt(curl, CURLOPT_URL, "");
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, request);

/* send all data to this function */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
/* pass 'chunk' struct to the callback function */
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&m_chunk);
res = curl_easy_perform(curl);

Any help would be appreciated.

List admin:
Received on 2011-05-30