Skip to content

Instantly share code, notes, and snippets.

@ooltcloud
Created January 1, 2015 10:23
Show Gist options
  • Save ooltcloud/3b5e539241b938b64b2c to your computer and use it in GitHub Desktop.
Save ooltcloud/3b5e539241b938b64b2c to your computer and use it in GitHub Desktop.
ホスト名文字列から Net.IPAddress を取得する
Public Shared Function GetIPv4FirstAddress(address As String) As Net.IPAddress
Dim entries = Net.Dns.GetHostAddresses(address)
For Each ip In entries
If ip.AddressFamily = Net.Sockets.AddressFamily.InterNetwork Then
Return ip
End If
Next
Return Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment