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 :: get length of enum values 
Csharp :: transform.rotate unity 
Csharp :: rotation facing mouse unity 
Csharp :: += meaning c# 
Csharp :: message uwp c# 
Csharp :: print in c# unity 
Csharp :: c# stringbuilder to file 
Csharp :: unity destroy all children 
Csharp :: how to check if a value is inside an array c# 
Csharp :: net use delete 
Csharp :: basic movement script unity 
Csharp :: c# repeat x times 
Csharp :: how to move mouse in c# 
Csharp :: despicable me 
Csharp :: unity json save array 
Csharp :: bootstrap modal popup 
Csharp :: reverse for loop 
Csharp :: Check if two linked lists merge. If so, where? 
Csharp :: unity clamp rotation 
Csharp :: c# restart app 
Csharp :: datagridview column color c# 
Csharp :: c# how to refreshyour bindingsource 
Csharp :: open folder dialog c# 
Csharp :: https port 
Csharp :: triangle minimum path sum c# 
Csharp :: add object to list c# 
Csharp :: c# run loop x times 
Csharp :: cannot convert from string to type T 
Csharp :: c# remove double quotes from string 
Csharp :: c# ftp file download 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =