有人能告诉我如何计算使用tcp套接字连接的进程的下载速度。
提前致谢
答案 0 :(得分:1)
当您开始接收数据时,请保留DateTime.Now。当您从TcpSocket收到时,您将获得收到的大小。
Average = TotalByteReceived /(Now.TotalSeconds - StartTimeTotalSeconds)
DateTime now = DateTime.Now;
while(true){
TotalSize += client.GetStream().Read(buffer,0,count)
//logic for your buffer
AverageBySecond = TotalSize / (DateTime.Now.TotalSeconds - now.TotalSeconds)
}