127.0.0.1
10.0.0.5
10.1.0.20
192.168.0.5
157.54.185.126
How can I determine which of these IP addresses, without connecting to the
remote machine, that if broadcast over that network interface, the remote
device could see the broadcast and also connect to the local machine at that
IP address. I was looking at some properties in the NetworkInterface class
and stuff, but nothing was obvious to me. I hope I am explaining the problem
well enough.
Thanks
> [...]
> How can I determine which of these IP addresses, without connecting to
> the
> remote machine, that if broadcast over that network interface, the remote
> device could see the broadcast and also connect to the local machine at
> that
> IP address.
Well, given your remote IP address, you should be able to apply your local
subnet mask to the remote address and each of your local addresses, and if
they result is equal then those addresses are on the same subnet.
But, you really shouldn't need to do this. Just broadcast to
IPAddress.Any, and assuming the remote machine is reachable, it will
receive the broadcast and can use the origin IP address to determine how
to connect back. There should be no reason for your local process to know
or care what the configured IP address is.
Pete