On Mon, 2010-10-25 at 01:50 +0200, Oscar Pernas wrote: > Hi all, > > Im using streamMessage to send data. I dont know why, but if I send > something by this way: > > streamMessage->writeString(key); > streamMessage->writeBytes(bytesParameter->getValue()); > > When i catch the message on reception I need to do two readBytes to catch > the bytes sent, like this: > > std::string key=streamMessage->readString(); > int sizeBytesData=packetDesc.at(++it); > std::vector<unsigned char> data(sizeBytesData); > streamMessage->readBytes(data); > streamMessage->readBytes(data); >
This is normal behavior for the StreamMessage, see the CMS API docs, the first call in your code will return the total number of bytes that was read, the second call should return -1 indicating there are no more bytes in that byte array element of the stream message, once you get the -1 then you are able to proceed to the next entry in the stream. > > Any clue? -- Tim Bish ------------ FuseSource Email: tim.b...@fusesource.com Web: http://fusesource.com Twitter: tabish121 Blog: http://timbish.blogspot.com/