views:

288

answers:

1

Hello!

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  A: 

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.

Martin v. Löwis
I've tried, but it does not help. I've put this code http://paste.org/pastebin/view/9564 between socket() and connect() calls, and it doesn't have any effect.
How do you know it didn't work?
Martin v. Löwis
Well, program behaved the same way as without bind(): after a timeout connect() returned SOCKET_ERROR.
Show your routing table: "netstat -r" or "route print" depending on the OS. Also, what IP addresses do the two interfaces have when you try this?
Warren Young