[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

[VB] Getting local IPV4

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 3

File: local ip.jpg (24KB, 447x171px) Image search: [Google]
local ip.jpg
24KB, 447x171px
I am using this to get my local IPV4 in VB but the thing is that I have 4 networks adapters, so it returns the wrong IP. The right one is on the third nic. But if I hardcode "addressList(2)" to get the third value, my code won't be universal... How is it possible to get the right IPV4 (the one that is linked with the nic that has an internet connection) on every computer ? Thanks.
>>
Dim entry As IPHostEntry = Dns.GetHostEntry(Dns.GetHostName)
Dim addressList As New List(Of IPAddress)
For Each address In entry.AddressList
If address.AddressFamily = AddressFamily.InterNetwork Then
addressList.Add(address)
MsgBox(address.ToString)
End If
Next
Dim interip As String = addressList(0).ToString
>>
>>282431
That's the original code, so it's easier in case you have the solution
>>
>>282429
>I have 4 networks adapters, so it returns the wrong IP.
What's wrong with it?
>>
>>282434
It's not connected to Internet nor to a router. All the other are like VMWare nics
>>
>>282451
It's not used or anything
>>
File: Capture.jpg (16KB, 401x139px) Image search: [Google]
Capture.jpg
16KB, 401x139px
how do I check for this with NetworkInterface ?
>>
File: Capture.jpg (33KB, 381x467px) Image search: [Google]
Capture.jpg
33KB, 381x467px
>>282508
how can I check if there's connectivity on a specific nic ?
>>
>>282510
same way windows does, ping an outside ip (microsoft) using that connection
>>
>>282531
fuck, me forgot link related
>http://blog.superuser.com/2011/05/16/windows-7-network-awareness/
>>
>>282537
how ?
but in the end I used:

Dim nics() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
For Each nic In nics
If nic.GetIPStatistics.BytesReceived > 50000 And nic.GetIPProperties.UnicastAddresses.Count > 0 And nic.OperationalStatus = OperationalStatus.Up And Not nic.NetworkInterfaceType = NetworkInterfaceType.Loopback And Not nic.IsReceiveOnly Then
For Each ip In nic.GetIPProperties.UnicastAddresses
If ip.Address.AddressFamily = AddressFamily.InterNetwork Then
End If
Next
End If
Next
Thread posts: 11
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.