Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private long lastCheck = 0;
- public new bool Connected
- {
- get
- {
- long crntCheck = Stopwatch.GetTimestamp();
- if (crntCheck - lastCheck > Stopwatch.Frequency)
- {
- lastCheck = crntCheck;
- IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
- TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();
- foreach (TcpConnectionInformation c in tcpConnections)
- if (c.LocalEndPoint.Equals(Client.LocalEndPoint) && c.RemoteEndPoint.Equals(Client.RemoteEndPoint))
- return c.State == TcpState.Established;
- return false;
- }
- else return base.Connected;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement