测量连接插座的时间 [英] Measuring time for a connected socket

查看:80
本文介绍了测量连接插座的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

In TCP/IP C# programming i want to know for how much time the socket was connected ?(THE EXACT TIME from the day it was connected until now)





我尝试了什么:



寻找代码..... .................................................. .........



What I have tried:

looking for code................................................................

推荐答案

使用Stopwatch Class(System.Diagnostics)| Microsoft Docs [ ^ ] - 它以刻度线工作,这是系统可以提供的最佳分辨率,并且可以运行长达290年。



连接时启动它,断开连接时停止它。在两者之间的任何时候你都可以使用teh Stopwatch.ElapsedTicks属性(System.Diagnostics)| Microsoft Docs [ ^ ]告诉你它连接了多长时间。
USe the Stopwatch Class (System.Diagnostics) | Microsoft Docs[^] - it works in ticks, which is teh finest resolution the system can provide, and runs up to 290 years.

Start it when you connect, stop it when you disconnect. At any point in between you can use teh Stopwatch.ElapsedTicks Property (System.Diagnostics) | Microsoft Docs[^] to tell you how long it's been connected.


这篇关于测量连接插座的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆