|
'modified by Thomas Fischer 04/2004 (http://www.thomas-fischer.org)
Imports System.Net
Imports System.Net.Dns
Public Class clsIP
Public Function GetLocalHostIP() As String
Dim objAddress As IPAddress
Dim sAns As String
Try
objAddress = New IPAddress( _
GetHostByName(GetLocalHostName).AddressList(0).Address)
sAns = objAddress.ToString
Catch ex As Exception
Debug.WriteLine(ex.Message)
sAns = ""
End Try
Return sAns
End Function
Public Function GetLocalHostName() As String
Return GetHostName()
End Function
Public Function IPToHostName(ByVal IPAddress As String) _
As String
Dim objEntry As IPHostEntry
Dim sAns As String
Try
objEntry = Resolve(IPAddress)
sAns = objEntry.HostName
Catch ex As Exception
sAns = ""
End Try
Return sAns
End Function
Public Function HostNameToIP(ByVal Host As String) As String
Dim objAddress As IPAddress
Dim sAns As String
Try
objAddress = New IPAddress(GetHostByName( _
Host).AddressList(0).Address)
sAns = objAddress.ToString
Catch
sAns = ""
End Try
Return sAns
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Thomas is interested in technical programming, networking and security technologies.
Currently he's studying at a german university