I’m trying to figure out the best cross platform solution to guarantee that a particular boost socket always binds to a particular network interface (eth0, eth4, etc).
I know how to resolve the interface to an address and I see that I can specify an tcp endpoint to tcp socket on construction or with bind, but I also need to specify the port.
Since I could be connecting to multiple servers in one instance, and have to deal with multiple instances of this library on the same machine, I can’t rely a fixed port number.
So my question(s):
Is there a reliable cross platform way to get an endpoint to an address without a port?
Or to do what boost tcp socket does by default, to get an unbound port for an address?
Or generally guarantee that the socket is bound to a particular network interface?
Short of finding a way to resolve ports, I don’t see a way to do this repeatedly. For some context, we are trying to eliminate routing tables to specify the interface to particular servers.
Thanks in advance for any suggestions!
Dan