Connect to two networks simultaneously

Solution 1:

For the first part, to connect to two networks at the same time I would set up static routes. Assuming that the networks are on different subnets, you're basically telling the system, "If you need to connect to a machine with an address of 192.168.2.X, use eth0. If you need to connect to a machine with an address of 192.168.3.X, use eth1. And here is the gateway you should use."

So in /etc/network/interfaces add these lines (with your own network information of course):

auto eth0
iface eth0 inet static
      address 192.168.2.2
      netmask 255.255.255.0
      up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

auto eth1
iface eth1 inet static
      address 192.168.3.2
      netmask 255.255.255.0
      up route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1

As far as what logic is required for the system to identify and handle a message in a certain way, I believe that would rely on the certain software you are using to process the messages.