I want to create an application to find whether a specific IP address on a network is online. I would already know the IP. I am pretty new to C#, but was wondering if anyone could just give me a simple solution. Thanks.
Ping ping = new Ping ();
IPAddress address = IPAddress.Parse("000.000.000.000");
PingReply pong = pingSender.Send(address);
pong
object contains information whether it was succesfull or not.
if (pong.Status == IPStatus.Success)
{
// your machine at address is up and responding
}
A complete program which would use this
using System;
using System.Net;
using System.Net.NetworkInformation;
public class Program
{
public static void Main()
{
Ping ping = new Ping();
//change the following ip variable into the ip adress you are looking for
string ip = " ";
IPAddress address = IPAddress.Parse(ip);
PingReply pong = ping.Send(address);
if (pong.Status == IPStatus.Success)
{
Console.WriteLine(ip + " is up and running.");
}
}
}