If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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

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..

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

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.

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

Originally Posted by hoxsiew

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.

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.?

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.

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

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.

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

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

Originally Posted by zeeshanaayan07

how to use wishark in network course

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!