|
Boost Users : |
Subject: Re: [Boost-users] ASIO, UDP and multiple Ethernet interfaces
From: Michael Procter (michael_at_[hidden])
Date: 2009-01-16 03:05:34
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net