|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
IP Recovery With C++Hello,
I have a question concerning a program that I am developing. The program itself needs the IP address of the local computer in order to work properly. The only problem is that I don't know a way to recover the machines ip address. And another problem arises if I want to work with the IP address: Routers. How will I be able to retrieve the good ip address (for instance my network connection status states that my ip is ***.***.***.** and if I go to www.whatismyip.com to retrieve my ip it states something completely different (the latter is the ip of the network and the first one was the ip that my engine got from my router) How to solve this problem? Thanks in advance, Dexter Dexter Drupsteen <DexterDrupst***@discussions.microsoft.com> wrote:
> The program itself needs the IP address of the local computer in order to The local machine may have several IP addresses, one for each network> work properly. The only problem is that I don't know a way to recover the > machines ip address. interface. For example, 127.0.0.1 is the loopback interface. Then, for each network card in the system attached to an IP network, there will be a different IP address. Here's a program which enumerates the IP addresses for the local machine: http://www.devcity.net/Articles/78/1/getipaddrs.aspx > And another problem arises if I want to work with the IP That is because of NAT, network address translation. Basically, the> address: Routers. How will I be able to retrieve the good ip address (for > instance my network connection status states that my ip is ***.***.***.** and > if I go to www.whatismyip.com to retrieve my ip it states something > completely different (the latter is the ip of the network and the first one > was the ip that my engine got from my router) router multiplexes all the machines inside the LAN across 1 or more external IP addresses. To get this information, you either need to talk to the network administrator, interface in a vendor-specific way with the router, or contact an external machine (such as www.whatismyip.com) to discover the external IP address. Note that NAT routers can multiplex multiple connections from the same machine across multiple IP addresses (and possibly multiple ISP connections, for speed or redundancy), so for independent requests the IP address may be different. -- Barry |
|||||||||||||||||||||||