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.