Using C++Builder2006
I'm modifying an old, small program which do these things:
(This 'cause the device can have a wrong IP/Netmask when installed and there's a need for a method IP-independent to set it. This is a well established method from the device producer, so it cannot be changed, i'm just describing what i'm doing).
The problem i'm facing is well described here: in short, Win7 does'nt send the UDP message through all the interfaces, but only through the "preferred" one. Since the program was built using an Indy UDPClient socket (TIdUDPClient) i'd like to keep it as it is.
Questions:
There's a way to "force" the UDP socket to send thru a specific Network interface?
TIdUDPClient
has a BoundIP
property for that exact purpose. You will have to call TIdUDPClient.Binding.CloseSocket()
each time you want to change the BoundIP
, unless you bind a different TIdUDPClient
object for each adapter.
This way i could "manually" loop and send the broadcast to all the (relevant) networks
Depending on the version of Indy you are using, you can use the TIdStack.LocalAddresses
property, or the TIdStack.AddLocalAddressesToList()
or TIdStack.GetLocalAddressList()
method, to get a list of available local IP addresses that you can then loop through.