Recipe 17.6. Pinging an IP Address


Problem

You want to perform a "ping" operation on a remote system.

Solution

Use the My.Computer.Network.Ping() method. The general syntax is:

   My.Computer.Network.Ping(targetSystem[, timeout]) 

targetSystem is a string IP address, a host name, or a System.Uri instance. The optional timeout argument is supplied in milliseconds and defaults to 500. This method returns true if the ping is successful, or False on failure or no response.

Discussion

If you receive a ping response from the remote system, it naturally means that the remote system is accessible. However, if you receive no response, this does not mean the remote system is inaccessible. It may have disabled responses to ping requests or a firewall or router between your system, and the remote system may have blocked the request or response.




Visual Basic 2005 Cookbook(c) Solutions for VB 2005 Programmers
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
ISBN: 0596101775
EAN: 2147483647
Year: 2006
Pages: 400

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net