DNS question??

piggybank1974
10-27-2004, 04:21 AM
I've just getting started on converting my network stuff from VB6 to vb.net.

I've got a question/s.

Here is my following code it retreives my network(IP address) and My internet IP address respectively.


Dim hostName As String = System.Net.Dns.GetHostName()


For a As Integer = 0 To Dns.GetHostByName(hostName).AddressList.Length - 1
TextBox1.Text += Dns.GetHostByName(hostName).AddressList(a).ToString & vbNewLine
Next a



AddressList(0) = Local IP Address (Network).
AddressList(1) = Internet IP Address.

Now what i'm trying to figure out is, will this always be so.

-- Questions --

(1) If the user has no network card will the Internet IP Address be at AddressList(0) or no Local IP address has been set will the Internet IP Address again it be at AddressList(0)

(2) if you are not connected to the net the AddressList(1) for the Internet IP Address should not be there, should it not.

What I'm trying to do is always get the Local IP address and always get the internet IP address, it needs to be reliable as possible.

the pig..

petbo
11-01-2004, 03:12 PM
Umm... What I do is make a winsock control, and then use the properties [something like winsock.ipaddress] to find my IP address... It seems to work a treat - but perhaps this isn't how you want to do it (added overhead etc)?

Pete

piggybank1974
11-02-2004, 01:51 AM
The trouble is with that is legecy code, the idea of using the Winsock control is pointless now in vb.net. and it should be banished completely.

the pig..

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum