// Method 2: write directly to message

  // Send the message as per usual

  Message msg;
  msg.getData().resize(100);

  memcpy(&msg.getData()[0], &i, sizeof(i));
  memcpy(&msg.getData()[4], &f, sizeof(f));
As far as I can see, this is wrong due to 3 reasons.

1. You can not resize "data" since it is a const.
2. Resizing a string is costly.
3. Copying stuff in to "data" alone is not sufficient as it is necessary to set the content length in the header as well.

Danushka

--
Danushka Menikkumbura
Technical Lead, WSO2 Inc.

blog : http://danushka-menikkumbura.blogspot.com/

http://wso2.com/ - "The Open Source SOA Company"


Reply via email to