在 2015-03-11 14:15:03,"Ray Satiro" <[email protected]> 写道:
On 3/10/2015 11:41 PM, 兰天 wrote:

Thanks for answering,I use libcurl 7.36,
in the callback function ,
size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata);

all the type I use is unsigned int,does that lead to the Failed writing body 
(-1 != 16384) ?



Please do not top-post [1]. I don't know why you'd see -1 because in the 
version of libcurl you claim to be using the format specifier is %zu [2] and 
that should print an unsigned integer not -1. Maybe someone else on the list 
can shed some insight on what could be happening there. Try getting the version 
string dynamically to see which libcurl is actually being used:

    printf("%s\n",curl_version_info(CURLVERSION_NOW)->version);

If you need more help please do what I said in my previous e-mail. Also can you 
post your write callback function?


My write callback function is follow:int Writer(char *data, size_t size, size_t 
nmemb, void *stream){    CURL_DATA_INFO *out = (CURL_DATA_INFO *) stream;    
unsigned int uiSizes = size * nmemb;unsigned int uiLoadContentLen = 0;    if 
(NULL == out || 0 == size || 0 == nmemb){LOG_ERR("NULL == out || 0 == size || 0 
== nmemb");//return -1;    }
if ( uiSizes <= out->uiBufLen - 
out->uiWriteBufLen){//LOG_DBG("uiSizes:%u,buffer length:%u,writen 
lengh:%u",uiSizes,out->uiBufLen, out->uiWriteBufLen);    memcpy(out->pszDownBuf 
+ out->uiWriteBufLen, data, uiSizes);out->uiWriteBufLen += 
uiSizes;if(out->uiWriteBufLen > out->uiBufLen){LOG_ERR("invalid write buf 
len:%u", out->uiWriteBufLen);}uiLoadContentLen = uiSizes;return 
uiLoadContentLen;}else{LOG_ERR("too large file, size=%u, writen=%u", uiSizes, 
out->uiWriteBufLen);//return -2;}//return 0;}after I running the program for 2 
hours  ,the programe stop with the follow infomations:* Failed writing body (1 
!= 16384)* Closing connection #21* Failed writing body (1 != 16384)* Closing 
connection #7* Operation timed out after 40000 milliseconds with 186810 out of 
269621 bytes received* Closing connection #58 [1]: 
http://curl.haxx.se/mail/etiquette.html#Do_Not_Top_Post
[2]: https://github.com/bagder/curl/blob/curl-7_36_0/lib/sendf.c#L459




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

Reply via email to