This question already has answers here:
How do I obtain the latency between server and client in C#?
(5 answers)
Closed 4 years ago.
enter image description here
I am trying to obtain the latency time between 2 servers. So how would it be possible to obtain it in milliseconds?
Is round trip time calculated while pinging the same as latency time?
Yes, just ping the other server, it's the latency.
See this question for examples: Using ping in c#
Related
This question already has answers here:
Does TcpClient write method guarantees the data are delivered to server?
(5 answers)
Can I free my data immediately after send() in blocking mode?
(2 answers)
what happens when I write data to a blocking socket, faster than the other side reads?
(2 answers)
Closed 2 years ago.
I created this proof of concept code to exercise my understanding of how Socket.Send behaves.
The host im pointing to is actually on Australia Central azure datacenter (and im in Brazil, so its half-world distance) and yet the avg TICK is between 40 and 70. And im not talking milliseconds, TICKS!
Can anyone explain to me what is going on?
I was expecting to have the avg milliseconds close to 200 or something... but right now its not even close to 1ms!
From the docs:
[...] A successful completion of the Send method means that the underlying system has had room to buffer your data for a network send.
So there's no guarantee that the data has actually reached the destination once the Send method returns.
This question already has answers here:
How to Query an NTP Server using C#?
(6 answers)
Closed 3 years ago.
I need to get the same time on all Instances of my program. How do I do that. DateTime.Now is not accurate(is different on different hardware) enough, I need to get the Time down to 100 ms difference-precision.
You don't want it read locally from each computer, as you don't know that each PC's clock is perfectly in sync (and you can see that they aren't).
So you have two options:
Write something on each computer to maintain precise time.
Get a web based time and all of your computers will be reading the same data. Here is an example from SO: How to get DateTime from the internet?
This question already has answers here:
Is TCP 100% reliable? [closed]
(3 answers)
How reliable is a TCP connection?
(2 answers)
How reliable is .NET TCP protocol?
(5 answers)
Closed 5 years ago.
I'm currently working with the assumption that when sending TCP data with System.Net.Sockets.Socket.Send ,I am guaranteed to get an exception if the connection drops. Is it possible to have a connection drop at the OS layer without receiving a notification/exception in the C# application on top?
I don't imagine there is such a case, in .net, but how would I go about demonstrating this to someone that is skeptical.
Actually as far as i know It is possible. Imagine you create a packet send it and it gets dropped by the way. Os should automatically retransmit when ttl timesout. It will retry few times before giving up. More advanced firewalls have one small option as I remember. Drop with or without notification. Second looks like packet was 'lost' on the way to destination. They actually receive it but let's say- sends them to null without any answer.
I do not know how exactly socket.send works but from network point of view it is possible to not get confirmation for every packet that was lost/dropped.
This question already has answers here:
How to detect when laptop power cable has been disconnected?
(7 answers)
Closed 9 years ago.
I'd like to call an API to know if the laptop is plugged into the wall. If it is I want to defer some CPU intense processing in order to save battery
I'd also like to be informed when this status changes (meaning when the user plugs the charger back in I'd like to be alerted)
in Win32 I'd probally go this route - RegisterPowerSettingNotification
is there something like this in .NET/C#?
I believe you can check SystemInformation.PowerStatus to see if it's on battery or not.
Boolean isRunningOnBattery =
(System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus ==
PowerLineStatus.Offline);
Edit: In addition to the above, there's also a System.Windows.Forms.PowerStatus class. One of its methods is PowerLineStatus, which will equal PowerLineStatus.Online if it's on AC Power.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to Query an NTP Server from C#
I try send email with my program but if time and date not set, sending is be fail.
How to update system time and date from internet in C#?
The answers to this question show you how to retrieve the time from a time server.
Are you sure you want to update the system time? Maybe it is sufficient to use the retrieved time in the email.