开发者

How to tell in protobuf-net how many bytes were read from a NetworkStream on a call to DeserializeWithLengthPrefix

开发者 https://www.devze.com 2023-01-22 13:12 出处:网络
Is there a way to do this? I would like to know how many bytes were read from a NetworkStream when I call DeserializeWithLengthPrefix. Since NetworkStream does not support the Position property I cann

Is there a way to do this? I would like to know how many bytes were read from a NetworkStream when I call DeserializeWithLengthPrefix. Since NetworkStream does not support the Position property I cannot see a simple way to 开发者_Python百科do this. Can this be done in a reasonably efficient way? I need to know this for profiling purposes, and it would be ideal to have the profiling overhead as low as possible.


Oh, that is an excellent question. That isn't currently exposed, but if desired I could add an overload with an out bytesRead (to include both the overhead of the lentgh-prefix and the object itself, since both have been consumed). I'm trying to avoid too many changes to "v1", but I could certainly add that into "v2" without too much bother.

0

精彩评论

暂无评论...
验证码 换一张
取 消