views:

67

answers:

3

My app needs to access two network cards. One to receive data (eth0) and another to send data (3G modem).

Normally, the kernel force the app to work with only one card at a time.

Is there any thing that I can do to make it run?

Thank you.

+3  A: 

The kernel does no such thing.

The kernel will route your traffic to the most appropriate end destination based upon the routing information and networks each card is assigned. However, if you are using TCP, your bidirectional communication will use only one route as there is only one address associated with that connection.

If you are trying to implement an multi-homing send/receive system, this is not supported in normal TCP - you will need to use a different protocol, likely implemented in the kernel.

Yann Ramin
Yes, that's the case. I forgot to point it out.I will receive multicasting from the Eth0 and send/receive TPC from the 3G modem.Is it still impossible?Thank you.
fpinheiro
+1  A: 

You can make two different UDP sockets bind to separate NICs with the bind(2) and send on one and listen on the other.

Nikolai N Fetissov
+2  A: 

The kernel is not forcing you to use a single interface. It just chooses a default interface if you don't specify otherwise. You can specify a specific interface by specifying it's IP address in the bind() command. To get a list of the available interfaces and their names, use the ioctl(SIOCGIFCONF) function.

Here's an example: http://techpulp.com/2008/10/get-list-of-interfaces-using-siocgifconf-ioctl/

Vagrant