specify outgoing port for udp packets
843790Sep 17 2009 — edited Sep 17 2009I'm working on a program that will be run on a Linux box with two Ethernet ports. Each port will be connected to a different router and thus each port can only access half the clients that will be communicating with us. This means that when we send UDP packets out to a client we must make sure that the packets go out of the right ethernet device. If we send to TCP address of client 1 using Ethernet B we will fail because Ethernet B is connected to a different router and can't access client 1.
I can and have configured the OS previously to get around this difficulty. The problem is my team will ultimately not control the environment our program is run in. Is there a way from within java to specify what outgoing IP address and/or device to send packets out of so they are delivered to the correct router?