Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-11
4
Medium Priority
?
165 Views
Last Modified: 2010-04-24
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?
0
Comment
Question by:tdomega
  • 3
4 Comments
 
LVL 19

Accepted Solution

by:
drichards earned 750 total points
ID: 12561827
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
 

Author Comment

by:tdomega
ID: 12575207
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
 

Author Comment

by:tdomega
ID: 12575417
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
 

Author Comment

by:tdomega
ID: 12575420
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question