Code for pinging the target System

Hi All,

I am Venkat, this is my first post to the group and I really looking forward the help from you people. I just wanted the C# code for continuously pinging the target system or if it is not possible to ping the target system continuously atleast the code in C# for pinging the target system.

Thanking you in Advance,
Venkat.

Comments

  • : I just wanted the C# code for continuously pinging the target system or if it is not possible to ping the target system continuously atleast the code in C# for pinging the target system.

    Easiest way would to call ping.exe like this (didn't test it):

    [code]
    while (true)
    {
    System.Diagnostics.Process proc =
    System.Diagnostics.Process.Start("ping.exe", "-n 1 www.domain.tld");
    proc.WaitForExit();
    if (proc.ExitCode != 0)
    {
    throw new Exception("Destination host unreachable");
    }
    }
    [/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion