cURL / Mailing Lists / curl-library / Single Mail

curl-library

bitmap buffer (c++)

From: <iamsal_at_interfree.it>
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.memory=NULL;
                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;
                error=curl_easy_perform(curl_handle);

//Here i use the buffer stored in the chunk

...
...
...
}

Anyone can help??
thanx in advance
best regards
manu

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