protobuf-net can write to (or read from) any Stream
implementation. FileStream
is just an example. In the case of communications between machines, this could be a NetworkStream
. If you just want to get an in-memory form, then use MemoryStream
. For example:
byte[] chunk;
using(var ms = new MemoryStream())
{
Serializer.Serialize(ms, obj);
chunk = ms.ToArray();
}
// now do something interesting with 'chunk'