Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

ping with c#

using System.Net.NetworkInformation;    

public static bool PingHost(string nameOrAddress)
{
    bool pingable = false;
    Ping pinger = null;

    try
    {
        pinger = new Ping();
        PingReply reply = pinger.Send(nameOrAddress);
        pingable = reply.Status == IPStatus.Success;
    }
    catch (PingException)
    {
        // Discard PingExceptions and return false;
    }
    finally
    {
        if (pinger != null)
        {
            pinger.Dispose();
        }
    }

    return pingable;
}
Comment

how to ping in c# forms

private void btnPing_Click(object sender, EventArgs e)
{
    Ping ping = new Ping();
    PingReply reply = ping.Send(txtIP.Text, 1000);
    MessageBox.Show(reply.Status.ToString(), "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Comment

ping with c#


using System.Net.NetworkInformation;    

public static bool PingHost(string nameOrAddress)
{
    bool pingable = false;
    Ping pinger = null;

    try
    {
        pinger = new Ping();
        PingReply reply = pinger.Send(nameOrAddress);
        pingable = reply.Status == IPStatus.Success;
    }
    catch (PingException)
    {
        // Discard PingExceptions and return false;
    }
    finally
    {
        if (pinger != null)
        {
            pinger.Dispose();
        }
    }

    return pingable;
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity override 
Csharp :: c# int to bool 
Csharp :: unity reload current scene 
Csharp :: init dictionary c# 
Csharp :: get request url in asp.net core 
Csharp :: c# check if list contains string case insensitive 
Csharp :: unity c# get bool from another script 
Csharp :: c# string to sha256 
Csharp :: c# loop through array 
Csharp :: set text in center wpf 
Csharp :: check animation end unity 
Csharp :: c# try catch with error message 
Csharp :: loop through multidimensional array c# 
Csharp :: stop process c# 
Csharp :: c# right click event 
Csharp :: c# string to datetime 
Csharp :: unity flexiable space 
Csharp :: c# get current milliseconds 
Csharp :: unity list 
Csharp :: ef core dbfirst 
Csharp :: disable script in unity 
Csharp :: how to usefor loop in c# 
Csharp :: C# how to remove an image in a folder 
Csharp :: Warum wächst Weizen besonders gut in den Steppen? 
Csharp :: getset c# 
Csharp :: c# filter non alphanumeric characters 
Csharp :: how to convert a number to 2 decimal places in c# 
Csharp :: change picturebox image c# 
Csharp :: instantiate scale object 
Csharp :: console writeline unity c# 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =