Ensure that each network has its own network range, e.g.
192.168.1.0/24. That answers your questions (2) and (3): check the source address of the "message" (what format is the message? UDP packet? How are you reading the message?) to identify what network the message came from, and you target a network by way of the IP address you're sending to. This is basic network routing...
Enable IP forwarding (
echo 1 > /proc/sys/net/ipv4/ip_forward) to let devices on one network connect directly to devices on the other network; set the Linux system as the (default) gateway on those devices.
As to how to configure Linux to connect to two networks simultaneously: that depends on your distribution and what tools you're using. With Debian without
networkmanager running you need to configure
/etc/network/interfaces appropriately; with Red Hat you need to configure the files under
EDIT: Disable the DHCP server on the WiFi routers, assign the LAN interface a fixed IP in the correct network as I described above (one in 192.168.0.0/24, e.g. 192.168.0.2 and on in 192.168.1.0/24, e.g. 192.168.1.2). Give each router its own wireless ID (and of course each its own passwod).
Give the interfaces in Linux corresponding address but then ending in .1. (As you've ordered a new system for Linux, ensure it has two interfaces, you may need to order an extra network interface card (NIC) to accomplish this.) Connect the Linux system to the WiFi routers via a LAN port; don't use the WAN port, i.e. the WiFi router is only used as an access point, it doesn't route anything. We leave the routing to Linux. (It should not be necessary to use
iptables as by default everything is permitted, and there's no need for NAT here. It may however be useful to use
iptables at a later stage to limit what traffic is permitted.)
Install a DHCP server in Linux, and configure it to hand out addresses on both interfaces (there's plenty of documentation to be found on how to do that). Configure the DHCP server to give the Linux system IP as the default gateway.