
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Pinging Programmatically
|
913
The client output looks like this:
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Received response: Thanks for the message!
Press Enter to exit...
The server output looks like this:
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
This is my message!
Press Enter to exit...
See Also
See the “Named Pipes,” “DllImport Attribute,” “IDisposable Interface,” and “GC.
SuppressFinalize Method” topics in the MSDN documentation.
16.6 Pinging Programmatically
Problem
You want to check a computer’s availability on the network.
Solution
Use the System.Net.NetworkInformation.Ping class to determine if a machine is avail-
able. In the
TestPing method, an instance of the Ping class is created. A ping request
is sent to www.oreilly.com using the
Send method. The Send method is synchronous
and returns a
PingReply that can be examined ...