1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Imports System.Net.NetworkInformation
Public Class HostHelper
Public Shared Function HostToIp(host As String, Optional isIp6 As Boolean = False) As String Try Dim pg As New Ping Dim pkey As PingReply = pg.Send(host, 1000) If pkey IsNot Nothing AndAlso pkey.Address IsNot Nothing Then If isIp6 Then Return pkey.Address.MapToIPv6.ToString End If Return pkey.Address.MapToIPv4.ToString End If Return String.Empty Catch ex As Exception Return String.Empty End Try End Function
End Class
|