programmatically access different NICs when sending web request
-
21-09-2019 - |
Question
hobbyist/non-profession programmer here. I don't have a strong grasp on network addressing.
I have a computer that simultainiously connects to two different networks. 1 through wireless, one by network cable.
In my DotNet (c#) windows form app, I would like it to send some requests to one of the networks through one of the NICs, and other requests through the other one.
How would I specify/set (some dotNet object property?) which network/NIC the request flows through?
Solution
Use Socket.Bind() before connecting to specify a particular local endpoint before establishing the connection. Depending on which of the 2 local ips you have you bind it should go through one interface or the other.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow