获取代理ping时间VB.Net

时间:2017-02-23 08:48:31

标签: vb.net proxy ip ping

我想ping代理并获得它的ping时间(例如:41ms)。

我尝试了这个有效的代码,但我没有得到ping时间。

If My.Computer.Network.Ping("216.58.194.51") Then
    MsgBox("Success")
Else
    MsgBox("Failed")
End If

1 个答案:

答案 0 :(得分:-1)

Dim Result As Net.NetworkInformation.PingReply
Dim SendPing As New Net.NetworkInformation.Ping
Dim ResponseTime As Long
Try
    Result = SendPing.Send("216.58.194.51")
    ResponseTime = Result.RoundtripTime
        If Result.Status = Net.NetworkInformation.IPStatus.Success Then
            MsgBox(ResponseTime.ToString) 'ResponseTime is response time
        Else
    End If
Catch ex As Exception
    MsgBox("No response")
End Try