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