Yes, you're right. You can force the socket to bind to a particular Network Interface. But this is done to override the primary decision the OS takes based on its routing tables. Furthermore, by making the application layer participate in the IP routing, you likely end up with fragile code and - to some extent - breaking the nice separation of the OSI layer model. After all, you'll have to maintain the binding network interface name and/or IP in the configuration of every client machine as they change over time.
Anyway, your choice ;) Please let us know if SuoNayi's approach works. Regards, Raúl. On Mar 6, 2013, at 15:04, jan wrote: > When I open a socket in Java to send/receive data, I can do the following: > > // open socket > dc = DatagramChannel.open(StandardProtocolFamily.INET6); > > // set options ... > > // bind to IP. The SocketAddress comes from the network-interface using > // NetworkInterface.getByName(networkIntf) > dc.bind(socketAddress); > > But that's the theory. I use ActiveMQ to receive JMS messages and write the > following: > > ActiveMQConnectionFactory connectionFactory = new > ActiveMQConnectionFactory("system", "manager", "tcp://some_server:61616"); > > From the preceding answer from SuoNayi, the following code should work: > > ActiveMQConnectionFactory connectionFactory = new > ActiveMQConnectionFactory("system", "manager", > "tcp://broker-ip:broker-port/local-ip:local-port?wireFormat.maxInactivityDuration=120000 > "); > > where the variable "local-ip" comes from the > NetworkInterface.getByName(networkIntf) object. > > However, I can't find any documentation. I will try this code tomorrow. > Further info is really appreciated. > > greetings > Jan > > > > > > -- > View this message in context: > http://activemq.2283324.n4.nabble.com/Best-protocol-network-interface-binding-tp4664240p4664435.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com.