2017-02-23 80 views
0

我想ping代理並獲得它的ping時間(例如:41毫秒)。獲取代理ping時間VB.Net

我試過這個代碼工作,但我沒有得到時間。

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

回答

-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