Question

Does the TcpClient class keep track of the number of bytes sent, received, and error counts or is there some other class that do something similar to that? I don't think the tcpclient class can do that.

Was it helpful?

Solution

No TcpClient does not keep such statistics. You could look at the interface statistics for pure send/receive (though it would include traffic other than TCP): MSDN

Most of the time TcpClient is wrapped in another class (at least it is when I use it). It would be trivial to track send/receive counts with such a wrapper.

OTHER TIPS

TcpClient does not do that. You can write yourself a small class that tracks this state. You could derive from Stream and build a reusable stream that tracks all kinds of metrics, and otherwise just relays all commands to another stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top