欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

VB.NET网络是否联通Function

程序员文章站 2022-04-12 13:02:31
''' ''' IP Ping ''' ''' IP地址 ''' 是否成功 ''' Private Funct ......

''' <summary>
    ''' IP Ping
    ''' </summary>
    ''' <param name="strIpOrDName">IP地址</param>
    ''' <returns>是否成功</returns>
    ''' <remarks></remarks>
    Private Function PingIpOrDomainName(ByVal strIpOrDName As String) As Boolean
        Dim objPingSender As New Ping
        Dim objPinOptions As New PingOptions()
        objPinOptions.DontFragment = True
        Dim data As String = theData
        Dim buffer() As Byte = Encoding.UTF8.GetBytes(data)
        Dim intTimeout As Integer = 120
        Dim objPinReply As PingReply = objPingSender.Send(strIpOrDName, intTimeout, buffer, objPinOptions)
        Dim strInfo As String = objPinReply.Status.ToString()
        If strInfo = "Success" Then
            Return True
        End If
        Return False
    End Function