BedrockFramework icon indicating copy to clipboard operation
BedrockFramework copied to clipboard

Question: custom protocol: is there a way to show bytes recv/sent

Open psantosl opened this issue 4 years ago • 3 comments

Hi!

Is this a good place to ask questions?

I'm looking into the custom protocol example. MyCustomProtocol.

Is there a way to obtain the number of bytes being sent/written?

The goal would be to print typical progress showing data transfer and so on.

Thanks!

psantosl avatar Feb 14 '20 19:02 psantosl

There isnt' a way to do this currently but it could be implemented as connection middleware that wraps the IDuplexPipe and stores that data in a feature. That might be something useful. What are you trying to show? Do you want all bytes ever transferred?

davidfowl avatar Feb 16 '20 06:02 davidfowl

Hi @davidfowl ,

There are 2 things I'd like to achieve:

  1. Client-side: good progress. If you implement some method-oriented thing on top of the protocol, you don't have fine-grained byte-per-byte progress unless you get it from the network. This could be done from the protocol, I think, I could have a workaround there.

  2. Server-side: it is super-handy to be able to print a log of every request, saying things like bytes recv/sent, time in recv/send, total request time, etc. In my current implementation (Stream based) I place a TrafficControlStream wrapping the NetworkStream and everything is tracked there. Old-fashioned.

pablo

psantosl avatar Feb 17 '20 20:02 psantosl

There isnt' a way to do this currently but it could be implemented as connection middleware that wraps the IDuplexPipe and stores that data in a feature. That might be something useful. What are you trying to show? Do you want all bytes ever transferred?

I was looking for something like this, but don't know the best way to implement it...I would like to know all the bytes ever transferred

gbaldera avatar Apr 29 '20 22:04 gbaldera