Essential Functions: getLocalIp() and ByteArToHex()

That I don’t want to re-write in case my hard drive breaks, all public domain:

Private Function getLocalIp() As String

        Dim myips As Net.IPHostEntry = System.Net.Dns.GetHostEntry(Net.Dns.GetHostName)

        Dim myip As String = “127.0.0.1”

        For Each ipaddress As Net.IPAddress In myips.AddressList
            If ipaddress.ToString.Split(“.”).Count = 4 Then
                If ipaddress.ToString <> “127.0.0.1” Then
                    myip = ipaddress.ToString
                    Exit For
                End If
            End If
        Next

        Return myip

    End Function

 


 

    Private Function ByteArToHex(ByVal byteAr As Byte())
        Dim s1 As String = “”
        For Each c1 As Byte In byteAr
            s1 = s1 + String.Format(“{0:X2}”, c1)

        Next
        Return s1

    End Function

 


 

Advertisements

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s