Share via


How to: Determine if a Remote Computer is Available in Visual Basic

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

You can use the Ping method to determine whether a remote computer or host is available. The server can be specified by URL, computer name, or IP address. Do not include https:// when specifying a URL.

The Ping method is not a fail-safe method for determining the availability of a remote computer: the ping port on the target machine may be turned off, or the ping request may be blocked by a firewall or router.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To ping a server

  • Determine whether the Ping method returns True. This example reports whether or not the server can be pinged, by determining whether the Ping method returned True. Replace 198.01.01.01 with the IP address, URL, or computer name of the server to ping

    If My.Computer.Network.Ping("198.01.01.01") Then
      MsgBox("Server pinged successfully.")
    Else
      MsgBox("Ping request timed out.")
    End If
    

To ping a server and specify a time-out

  • Determine whether the Ping method returns True, specifying the time-out interval in milliseconds. If no time-out is specified, 500 is used as the default. This example reports whether or not the server can be pinged, by determining whether the Ping method returned True, and it specifies a time-out interval of 1000 milliseconds. Replace www.cohowinery.com with the IP address, URL, or computer name of the server to ping.

    If My.Computer.Network.Ping("www.cohowinery.com", 1000) Then
      MsgBox("Server pinged successfully.")
    Else
      MsgBox("Ping request timed out.")
    End If
    

See Also

Tasks

How to: Check Connection Status in Visual Basic

Reference

Network

Ping