I've been searching the net for answers but I can't seem to find a complete answer.
Scenario: I have a client API and a server. An application uses the client API to talk to the server. Both TCP and UDP are used to communicate between the client API and the server. All of this has been written using ASIO.
The client API connects to the server via TCP, then sends commands via TCP and receives responses via TCP. The client API also listens to a UDP address where it receives real-time data continuously.
The environment is a mix of machines running WIN32 and WIN64. All of the machines also have 2 network cards.
Question: I would like to be able to 'pin' my TCP and UDP connections to specific local network interfaces. I have seen some info that discusses the SO_BINDTODEVICE
socket option as well as the bind function from earlier posts or other sites.
Is it possible to do this in the WIN32/64 environment? If you could shed some light on this, some examples, or sites that are helpful I would really appreciate it.
Links I've found:
You can bind to a specific endpoint using the appropriate tcp::ip::acceptor
constructor
include <boost/asio.hpp>
int
main()
{
using namespace boost::asio;
io_service service;
ip::tcp::endpoint ep(
ip::address::from_string( "127.0.0.1" ),
1234
);
ip::tcp::acceptor acceptor(
service,
ep
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With