Hi,

I want to write chat example using libcurl.

i.e
Connect to server
Send a message to server
Read message from server

I tried sendrecv example from  [ as in
http://curl.haxx.se/libcurl/c/sendrecv.html]

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: 127.0.0.1\r\n\r\n";
curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1";);
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.


Thanks
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to