when i open a socket on one adapter when the other is disconnected both of them works fine.
but when both are connected and i open sockets on both of them only the 3G EVDO device socket works.
I have binded both the sockets to their respective adapters local IP. and both of them are connecting to the same remote ip (where server application is running) but on different ports.

please tell me that is there any way that both the sockets can work simultaneously..??
please help me..

Thanks and regards
Hussain Aftab

April 29th, 2010, 07:13 AM

hoxsiew

Re: how to open sockets on multiple network adapters..??

Binding each socket to its respective adapters should be sufficient. You say one doesn't work. What doesn't work? connect? send/recv? Are there any errors returned and what are their codes?

What does your bind code look like?

April 29th, 2010, 01:33 PM

MikeAThon

Re: how to open sockets on multiple network adapters..??

Quote:

Originally Posted by hoxsiew

Binding each socket to its respective adapters should be sufficient.

I tend to disagree with this, at least with respect to outgoing (i.e., client) connections. For a multi-homed system (i.e., a system with multiple network cards) with a Windows OS, and with respect to outgoing connections, a call to bind() will have no effect on the choice of which card will be used to establish the connection. Rather, the choice of card will be made by the OS using the routing table. The OS will make its decision by comparing the routing table to the destination IP, to choose the card that seems most appropriate for the destination.

Yes, I see. I was incomplete in my description. The bind must use the adapter address:

Even with the address of the adapter, my point was that for an outgoing connection, the call to bind() is ignored and will not effectuate a selection of the specified adapter. In Windows, it's the OS that chooses the adapter for outgoing connections, and it does so at the time of the call to connect(), based on a comparison of the IP address of the destination to the information in the routing table.

The address of the destination does not come into play until the call to connect(), such that any prior call to bind() is effectively ignored for outgoing connections on a multihomed system.

April 29th, 2010, 09:21 PM

hoxsiew

Re: how to open sockets on multiple network adapters..??

I must be having a senior moment or something. I'm confusing bind/listen/accept on the server server side of things. Please ignore anything I've said so far.

April 30th, 2010, 03:52 AM

hussain_kiet

Re: how to open sockets on multiple network adapters..??

I agree with MikeAThon.
It seems that binding a socket to a network adapters ip doesn't do the trick. because if you see the routing table of windows it shows the Default gateway to the EVDO device and therefore all the packets are being routed towards that adapter..
we need to change the default gateway or something in the routing table as the article on the given link said. http://ce4all.blogspot.com/2007/05/r...specified.html
but i didn't understand how to use those functions and what i have to include in my code to get access to those functions.?

April 30th, 2010, 03:44 PM

MikeAThon

Re: how to open sockets on multiple network adapters..??

Before trying to accomplish this programmatically, you might want to confirm that it works if you add an entry to the routing table manually.

Add the entry manually, and then see if your program works as expected, i.e., confirm that one card is selected for one destination IP address, and the other card is selected for a second destination IP address.

So how can a client choose what NIC to use? A client can also choose to call bind() if it so desires, after socket() and before connect(). Usually this isn't done simply because connect() will automatically bind an unbound socket in a way that enables access via any NIC (which is usually the desired behaviour), but this auto-binding can be turned off by calling bind() explicitly. In this case, you should specify 0 for the port number to have the OS choose a random port number for you.

The documentation for winsock says "If the socket is unbound, unique values are assigned to the local association by the system, and the socket is marked as bound." I suppose one might read that as "if connect() causes unbound sockets to auto-bind, then pre-bound sockets will get to use whatever association they were bound with". But really, the wording is ambiguous so i don't know if it's safe to make that conclusion based on the winsock documentation.

What does this question have to do with the OP which is "how to open sockets on multiple network adapters..?"?
Please, remove this post here and create a new thread with the complete problem description!