By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Getting the right IP address when multiple are present

!NoItAll
100+
P: 296
Ok - I have a socket library that allows me to pass data around a network. The basic design is that I send a request to the service for the data I want and include my return address (my IP address) where I am waiting for the answer.
The "return" address is the IP address of the machine from where I send the request, and where I expect the service on the other end to return the requested data.
Here's my issue. On some computers there are multiple IP addresses. This happens when a user is running a VPN, or if there are more than two NICs installed. It's easy to get all of these IP addresses, but only ONE is the correct one to send to my service. While VPNs typically are going to be the last one in the list, second NICs can be in any order.
My question is: What do others do to address this issue?

A couple of ideas I've had are:

1. Compare the IP addresses with the IP address of the server to see which one is "closest" to the server address numerically.

2. Force the user to tell the client which IP address to use for it's return address.

3. Rely on the DNS - but in some networks this just doesn't seem to be reliable.
Oct 13 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.