lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

tcp: connect: Add source_address and bind_device options #154

Closed kgraefe closed 1 year ago

kgraefe commented 1 year ago

This change allows binding an outgoing TCP connection to a specific network interface. My use-case for that is that I need to support situations where two interfaces are configured for link-local addressing. In that case the system has two different routes into the link-local subnet.

On Windows the interface is determined by the IP address passed to bind(). On Linux this is not sufficient as the routing table takes precedence. Therefore we must explicitly bind the socket to the interface.

Depends on #153

lemunozm commented 1 year ago

Thanks again for another awesome contribution! 🚀