cURL / Mailing Lists / curl-library / Single Mail


bitmap buffer (c++)

From: <>
Date: 13 Nov 2008 12:08:11 -0000

I use curl-easy to receive a bitmap buffer by a network camera, but the buffer doesn't arrive
always complete, the more if i use many applications doing the same thing...
I would like to know if there is a way to force curl to take ALL the buffer.
Here is a piece of the code (C++)

struct MemoryStruct {
                        unsigned char *memory;
                        size_t size;

size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
                register int realsize = size * nmemb;
                struct MemoryStruct *mem = (struct MemoryStruct *)data;
                mem->memory = (unsigned char *)realloc(mem->memory, mem->size + realsize + 1);
                if (mem->memory) {
                        memcpy(&(mem->memory[mem->size]), ptr, realsize);
                        mem->size += realsize;
                        mem->memory[mem->size] = 0;
                return realsize;

void conta() throw (std::runtime_error){
                CURL *curl_handle;
                char* info;
                struct MemoryStruct chunk;
                chunk.size = 0;
                curl_handle = curl_easy_init();
                curl_easy_setopt(curl_handle, CURLOPT_URL, url);
                curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
                curl_easy_setopt(curl_handle, CURLOPT_HEADER,false);
                curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
                CURLcode error;

//Here i use the buffer stored in the chunk


Anyone can help??
thanx in advance
best regards

Vuoi essere presente online?
Vuoi dare voce alla tua attivita`?
Acquista un dominio su
A partire da 18,59 euro
Received on 2008-11-13