On Windows, a call to bind() affects card selection only incoming traffic, not outgoing traffic.
Thus, on a client running in a multi-homed system (i.e., more than one interface card), it's the network stack that selects the card to use, and it makes its selection based solely on the destination IP, which in turn is based on the routing table. A call to bind() will not affect the choice of the card in any way.
It's got something to do with something called a "Weak End System" ("Weak E/S") model. Vista changed to a strong E/S model, so the issue might not arise under Vista. But all prior versions of Windows used the weak E/S model.
With a weak E/S model, it's the routing table that decides which card is used for outgoing traffic in a multihomed system.
See if these threads offer some insight:
"Local socket binding on multihomed host in Windows XP does not work" at http://www.codeguru.com/forum/showthread.php?t=452337
"How to connect a port to a specified Networkcard?" at http://www.codeguru.com/forum/showthread.php?t=451117. This thread mentions the CreateIpForwardEntry() function, which (I think) can be used to create an entry in the routing table so that all outgoing IP traffic with a specified server is routed via a specified adapter.
"Working with 2 Ethernet cards" at http://www.codeguru.com/forum/showthread.php?t=448863
"Strange bind behavior on multihomed system" at http://www.codeguru.com/forum/showthread.php?t=452368
转载:http://blog.sina.com.cn/s/blog_54b5ea250100ktgi.html