Home Forums Support Send a Count of bytes Reply To: Send a Count of bytes

#3303
Anonymous
Inactive

Thanks MarcF,

I’ve got my head round that and am implementing something suitable.
One question though. I’ve got rough code of the form…


                Message.Serialise();

                MemoryStream memoryStream = new MemoryStream(Message.Bytes);
                StreamTools.ThreadSafeStream threadSafeStream = new StreamTools.ThreadSafeStream(memoryStream);
                StreamTools.StreamSendWrapper streamSendWrapper = new StreamTools.StreamSendWrapper(threadSafeStream, Message.BaseOffset, Message.Length);
                Connection.SendObject(Message.Type, streamSendWrapper);

                Message.FreeInternalBuffer();

The thing that bothers me is the last line, the freeing up of the internal buffer in the message.
This just returns the buffer back to the pool for immediate re-use by something else.
But, i’m not sure what happens with the SendObject call just prior.
Does this make a copy of the data as specified by the stream calls previous or might the buffer still not be sent?

Obviously, if the SendObject call relies on the original data being in place for a period of time, it would be bad for something else to start writing all over it. 🙂

cheers

  • This reply was modified 9 years, 10 months ago by .
  • This reply was modified 9 years, 10 months ago by .