Click here to Skip to main content
14,327,007 members
Rate this:
Please Sign up or sign in to vote.
See more:
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................................................................
Posted
Updated 17-Aug-18 20:00pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100