Using "ping" inside of C#

Hi,

I need my program to be able to determine if the web connection is still active.  Does anybody have the source code handy that I need, in order to do this?


Thanks,
Bob
ba272Asked:
Who is Participating?
 
WebSpecialsCommented:
private void Ping(string hostname)
{
    //Create ping object
    Ping netMon = new Ping();
I think that is what you need

    //Ping host (this will block until complete)
    PingResponse response = netMon.PingHost(hostname, 4);

    //Process ping response
    if (response != null)
    {
        ProcessResponse(response);
    }
}
(cite: CodeProject)

For more Information:
http://www.codeproject.com/useritems/CSharpPing.asp
0
 
ba272Author Commented:
Thanks a lot.  I'm having a little difficulty getting this to compile, but its just what I needed.

Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.