Click here to Skip to main content
15,867,906 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

How to PING Server in C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
13 Sep 2010CPOL 20.4K   2   7
using System;using System.Runtime;using System.Runtime.InteropServices;public static class InternetConnectionStatus{ [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int Description, int Reserved); public static bool Connected() { ...
C#
using System;
using System.Runtime;
using System.Runtime.InteropServices;
public static class InternetConnectionStatus
{
    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState(out int Description, int Reserved);
    public static bool Connected()
    {
        int Descript;
        return InternetGetConnectedState(out Descript, 0);
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
President 6D Systems LLC
United States United States
I studied Software Engineering at Milwaukee School of Engineering for 2 years before switching to Management of Information Systems for a more business oriented approach. I've been developing software since the age of 14, and have waded through languages such as QBasic, TrueBasic, C, C++, Java, VB6, VB.NET, C#, etc. I've been developing professionally since 2002 in .NET.

Comments and Discussions

 
QuestionGreat tip Pin
Marco Bertschi22-Jan-14 20:35
protectorMarco Bertschi22-Jan-14 20:35 
AnswerRe: Great tip Pin
Ron Beyer23-Jan-14 2:41
professionalRon Beyer23-Jan-14 2:41 
GeneralRe: Great tip Pin
Marco Bertschi23-Jan-14 2:54
protectorMarco Bertschi23-Jan-14 2:54 
GeneralRe: Great tip Pin
Ron Beyer23-Jan-14 2:57
professionalRon Beyer23-Jan-14 2:57 
GeneralRe: Great tip Pin
Marco Bertschi23-Jan-14 3:00
protectorMarco Bertschi23-Jan-14 3:00 
GeneralThis will not help if you are working inside of a company wi... Pin
Steve Maier14-Sep-10 5:04
professionalSteve Maier14-Sep-10 5:04 
GeneralGood alternate for Ping. Pin
Abhishek Sur13-Sep-10 12:14
professionalAbhishek Sur13-Sep-10 12:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.