|
-
Feb 1st, 2012, 02:54 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Getting the real IP address
Hello.
In a WinForm application, if you want to get the IP address of the machine the code is running on (for instance, to log in the database what the IP address is when a user deletes a record), I would use this code:
Code:
Dim xEntry As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
Dim ipAddr As Net.IPAddress() = xEntry.AddressList
lblIP.Text = ipAddr(0).ToString()
While the code works, and it returns the correct IP address (for example: 140.139.138.137), Visual Studio doesn't like that code, and tells you that GetHostByName is obsolete, and needs to be replaced with GetHostEntry.
But if i do that, then i get back something that does not look like an IP address: fe80::28ba:e091:1056:949f%11
So my question is, if i'm not supposed to use GetHostByName because it's been replaced by GetHostEntry, how come GetHostEntry doesn't give me the IP address?
.
~Peter

Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|