开发者

Getting IP address of my computer

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜