开发者

Getting IP address of my computer

开发者 https://www.devze.com 2023-01-28 10:08 出处:网络
How can I get the IP add开发者_开发问答ress of my computer (on which my application is running)

How can I get the IP add开发者_开发问答ress of my computer (on which my application is running) in vb.net

Thanks Furqan


See System.Net.DNS.

Something like this should work:

Dim ips As IPAddress() = Dns.GetHostAddresses(Dns.GetHostName())

Dim index As Integer
For Each ip in ips
     Console.WriteLine(ip)
Next ip


One way is to use System.Net.Dns.GetHostAddresses, passing it the empty string. Note that it will give you an array of addresses, this is because a host can have multiple addresses, one for each interface. A common example would be the loopback address (127.0.0.1) and one or more public facing IP addresses (eg 10.10.1.1). If your machine has a specific host name you can use that instead of the empty string.

0

精彩评论

暂无评论...
验证码 换一张
取 消