2x adsl : how to tell socket which one to use?

Hi,

I have acces to 2 adsl-connections. One over lan-router, and second over wlan. Each networkcard has another ip-address, but the routers ip can be the same (not usually but since these are two independent connections its could be possible)

I have a socket class, and want to do loadbalancing, how can i choose which way i want to go...can i choose the networkcard for each socket, or maybe only the router?
Right now, sockets seem to prefer the lan connection...Any Ideas?
tdomegaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

drichardsCommented:
If you want to select which interface is used, you need to explicitly bind the socket to the interface you want to use - set the address to the desired interface and set the port to 0 to have the system select the outgoing port or set it manually along with the address.  See the Winsock bind command (unmanaged C++) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/bind_2.asp or the Socket.Bind method (managed C++) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetsocketssocketclassbindtopic.asp .

And your routers should NOT have the same address.  How would they get that way?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tdomegaAuthor Commented:
hi,

i dont get the bind to work....
ep = new IPEndPoint(IPAddress::Parse(S"192.168.2.1"),0);  //*.*.2.1 is the ip of one router
an then bind(ep);
says ip is invalid in this context


and for the routers, both are set up by different admins, and if one changes the internal ip address it could happen that both have the same...
can i somehow enumerate all possible networkcards capabe of outgoing connections?
0
tdomegaAuthor Commented:
ok, i got it to work...should not hardcode the ip-address :)

Dns::GetHostByName(Dns::GetHostName())->get_AddressList()

returns an array of all IPAddresses my computer has which then binded to the connecting socket tells it to use the network card with this specific ip...

Thanks!
0
tdomegaAuthor Commented:
ok, i got it to work...should not hardcode the ip-address :)

Dns::GetHostByName(Dns::GetHostName())->get_AddressList()

returns an array of all IPAddresses my computer has which then binded to the connecting socket tells it to use the network card with this specific ip...

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.