Using "ping" inside of C#

Posted on 2005-04-10
Last Modified: 2008-03-10

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?

Question by:ba272
    LVL 2

    Accepted Solution

    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)
    (cite: CodeProject)

    For more Information:

    Author Comment

    Thanks a lot.  I'm having a little difficulty getting this to compile, but its just what I needed.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now