perform connect() on specific network adapter

2020-07-29 02:07发布

I'm programming with Winsock2. I have two network adapters in system, one for local connections (LAN), one for outer connections (PPPOE). When I perform a connect() call to connect to local address, it uses PPPOE adapter instead of LAN. I know I could tweak this using metrics, but can't I just use some hard-code to forcibly use LAN adapter? Thanks in advance!

1条回答
男人必须洒脱
2楼-- · 2020-07-29 02:30

Before you connect(), you need to bind() to the IP address of the LAN adapter. Just specify the IP address, and leave the port open (i.e. 0), so that the system can still chose one.

查看更多
登录 后发表回答