pizheng / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
Other
0 stars 0 forks source link

lock the namedpipe #145

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hello, Marc

I try to use protobuf-net to serialize an custom object and write it to a named 
pipe though c# PipeClientStream. the Serializer seems lock up the pipe and I 
have to close the Pipe in order for the PipeServerStream to be able to read the 
pipe? 

is this normal? both client and server reference to the same protobuf-net.dll

will the singleton design cause such lock?

thanks

Max

Original issue reported on code.google.com by maxzh...@gmail.com on 3 Dec 2010 at 3:24

GoogleCodeExporter commented 9 years ago
The serializer? or the deserializer? A feature of the protobuf wire format 
(defined by Google) is that it *does not include termination data* by default; 
so it has no way of knowing when the data is complete (for technical reasons 
you can't assume any point is the end) - and thus it will keep reading until 
the input stream is closed. However, if you use SerializeWithLengthPrefix and 
DeserializeWithLengthPrefix, protobuf-net includes some extra metadata to allow 
it to consume (repeatedly) a single object from a stream *without* having to 
close the stream.

So; try the *WithLengthPrefix methods; does this fix it?

Original comment by marc.gravell on 3 Dec 2010 at 6:19

GoogleCodeExporter commented 9 years ago
You are the man, Marc. It fix the issue. 

Maybe the gettingstart document needs to be updated for newbies like me.

Original comment by maxzh...@gmail.com on 3 Dec 2010 at 2:11

GoogleCodeExporter commented 9 years ago

Original comment by marc.gravell on 4 Dec 2010 at 11:37