June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to retrieve the IP address of the current computer, perhaps to use later in networking code.
Use the System.Net.Dns class, which provides shared GetHostName and GetHostByName methods.
The Dns class provides domain name resolution services. You can invoke its GetHostName to retrieve the host name for the current computer. You can then translate the host name into an IP address using GetHostByName.
Dim HostName As String Dim IPAddress As String ' Look up the host name and IP address. HostName = System.Net.Dns.GetHostName() IPAddress = System.Net.Dns.GetHostByName(HostName).AddressList(0).ToString() Console.WriteLine("Host name:" & HostName) Console.WriteLine("IP address:" ...Read now
Unlock full access