Get Ping in Milliseconds

This function gives the programmer the ability to determine the time in milliseconds of a response from an IP address. This could be useful for determining lag or for a game's server browser, etc.


''' <summary>
''' Gets the time taken to ping an IP.
''' </summary>
''' <param name="hostNameOrAddress">IP or HostName to ping</param>
''' <returns>The time in milliseconds taken to ping the IP.</returns>
''' <remarks></remarks>

Public Shared Function GetPingMs(ByRef hostNameOrAddress As String)
    Dim ping As New System.Net.NetworkInformation.Ping
    Return ping.Send(hostNameOrAddress).RoundtripTime
End Function

' How to call this function (IP Address).

' How to call this function (HostName).

See Also

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License