Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // addressToPing can be an IPaddress or host name.
- // returns a boolean indicating successful ping
- public static bool PingComputer (string[] addressToPing)
- {
- Ping pingSender = new Ping ();
- PingOptions options = new PingOptions ();
- // Use the default Ttl value which is 128,
- // but change the fragmentation behavior.
- options.DontFragment = true;
- // Create a buffer of 32 bytes of data to be transmitted.
- string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- byte[] buffer = Encoding.ASCII.GetBytes (data);
- int timeout = 120;
- PingReply reply = pingSender.Send (args[0], timeout, buffer, options);
- return reply.Status == IPStatus.Success;
- }
Add Comment
Please, Sign In to add comment