I am not sure what is going on. Something related with buffering. The … code …
if (data->inbound){
//fwrite(buf, res, 1, stdout); //data->inbound);
char tmp[SOAP_BUFLEN+1];
memset(tmp,0,SOAP_BUFLEN+1);
if(len>0) {
memcpy(tmp, buf, minim(SOAP_BUFLEN,len) );
tmp[minim(SOAP_BUFLEN,len)] = '\0';
printf("%s\n",tmp);
//printf("-----------------\n");
}
when I use fwrite I see the output with no problems. When I use memcpy I see duplicate entries in the output? Do I need to fflush something?
At the end of the printf statement I see a portion of the tmp to be repeated.
You are using different length values for fwrite vs memcpy. Based on the code (and commented out code) here, memcpy uses the lesser of
lenorSOAP_BUFLEN. fwrite usesres * 1. So I’d betlen != res.