code_junkie

How can I monitor active computers on my network in ASP.NET

Nov 13th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. // addressToPing can be an IPaddress or host name.
  2. // returns a boolean indicating successful ping
  3. public static bool PingComputer (string[] addressToPing)
  4. {
  5. Ping pingSender = new Ping ();
  6. PingOptions options = new PingOptions ();
  7.  
  8. // Use the default Ttl value which is 128,
  9. // but change the fragmentation behavior.
  10. options.DontFragment = true;
  11.  
  12. // Create a buffer of 32 bytes of data to be transmitted.
  13. string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  14. byte[] buffer = Encoding.ASCII.GetBytes (data);
  15. int timeout = 120;
  16. PingReply reply = pingSender.Send (args[0], timeout, buffer, options);
  17. return reply.Status == IPStatus.Success;
  18. }
Add Comment
Please, Sign In to add comment