MrDoDo
MrDoDo

Reputation: 35

Winsock - Connect to Internet through specified adapter

I try to write a program using WINSOCK. I am trying to connect to the internet from a laptop with some network adapters ( LAN, WIRELESS,An USB ADSL Modem). It sounds, when I call connect function, it tries to connect using LAN, so because LAN is not connected it fails. Here are my questions: 1)How can I force a socket to use a specified Network Adapter? 2)How can I find which adapter is connected to internet? Thanks for reading and answering

Upvotes: 0

Views: 1176

Answers (1)

xaxxon
xaxxon

Reputation: 19761

Before calling connect(), use bind() on the socket and specify the local IP of the desired interface. It's fine to call bind() on a client socket -- just don't call listen().

Upvotes: 2

Related Questions