ASIO, UDP and multiple Ethernet interfaces
I have a machine with two Ethernet interfaces. I want to create a UDP socket for each interface, so that I can send datagrams out separately over each interface. I have the IP addresses for each interface. How do I connect these up to the sockets so that they use the proper Ethernet interface? Thanks, Jeff Diewald JEOL USA
Jeff Diewald wrote:
I have a machine with two Ethernet interfaces. I want to create a UDP socket for each interface, so that I can send datagrams out separately over each interface.
I have the IP addresses for each interface. How do I connect these up to the sockets so that they use the proper Ethernet interface?
When you call bind on the socket, the udp::endpoint that you supply should have the interface address in it, rather than simply a protocol. This binds the socket to a specific local address. That is to say, make your endpoint with this constructor: boost::asio::ip::udp::endpoint(const boost::asio::ip::address & addr, unsigned short port_num); and not the one that takes only a protocol and port number. Best regards, Michael Procter
participants (2)
-
Jeff Diewald
-
Michael Procter