Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi codeproject friends,

how I can implement a loop to ping ip addresses exemple :
ping from 192.168.1.2 to 192.168.1.255
I want a simple algorithm or a simple program in C# exmplain this work...
thank you codeproject members
Posted

Have a look at the Ping class[^].
 
Share this answer
 
Hi

Check with this
C#
Array.ForEach(Enumerable.Range(2, 255).ToArray(), i =>
               {
                   var reply = new Ping().Send(string.Format("102.168.1.{0}", i));
               });
 
Share this answer
 
Comments
pablo ramos1 20-Sep-11 10:31am    
Thank you Kris, there is not another code to cover all the bits example: 192.168.1.1 to 200.180.30.0
Thx
C# has an in-built class named 'Ping'
See here
see Ping.send method in this

Also refer below links
http://www.codeproject.com/KB/IP/pingdotnet.aspx
http://www.dreamincode.net/forums/topic/71263-using-the-ping-class-in-c%23/
 
Share this answer
 
Comments
Rob Philpott 20-Sep-11 8:26am    
Wow, you really do learn something new everyday. Had no idea that was in there. Very nice.
AditSheth 21-Sep-11 0:04am    
thanks
Namespace Required : System.Net.NetworkInformation;

Ping objPingSender = new Ping();
PingReply objPingReply = objPingSender.Send(strIpAddress);

 switch (objPingReply.Status)
 {
    case IPStatus.Success:
         return true;

    default:
        return false;
 }   
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900