How to check the response time of a remote machine?

Leila KHAMMASSI 571 Reputation points
2023-06-02T20:07:43.6266667+00:00

Hello!

How to check the response time of a remote machine?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,584 questions
F#
F#
A strongly typed, multi-paradigm programming language developed by the F# Software Foundation, Microsoft, and open contributors.
60 questions
.NET F#
.NET F#
.NET: Microsoft Technologies based on the .NET software framework.F#: A strongly typed, multi-paradigm programming language developed by the F# Software Foundation, Microsoft, and open contributors.
98 questions
0 comments No comments
{count} votes

Accepted answer
  1. Osjaetor 475 Reputation points
    2023-06-03T20:52:25.3033333+00:00

    Hi 12586429,

    
    using System;
    using System.Net.NetworkInformation;
    
    public class Program
    {
        public static void Main(string[] args)
        {
            string remoteIpAddress = "192.168.0.1"; // Replace by your remote IP machine
    
            Ping pingSender = new Ping();
            PingOptions options = new PingOptions();
      
            byte[] buffer = new byte[32];
            
            try
            {
                PingReply reply = pingSender.Send(remoteIpAddress, 1000, buffer, options);
                
                if (reply.Status == IPStatus.Success)
                {
                    Console.WriteLine($"Response time: {reply.RoundtripTime} ms");
                }
                else
                {
                    Console.WriteLine($"Ping failed with status: {reply.Status}");
                }
            }
            catch (PingException ex)
            {
                Console.WriteLine($"Ping failed error: {ex.Message}");
            }
        }
    }
    
    

    Regards,

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful