简体   繁体   中英

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

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM