Interface binding in java TCP connection

I have two interfaces in the Solaris lobby. I would like to initiate two TCP connections to one TCP server through both interfaces, as shown in the diagram. Is there any way in Java to bind an interface to a TCP socket to override the local routing table?

I am connecting a network diagram,

network_diagram

I would like to use as the bandwidth of serial lines to receive data from the server. Therefore, I would like to initiate a connection on both interfaces.

thanks,

+6
source share
2 answers

you can use

Socket s = new Socket(hostname, port, localInterface, 0); 

However, many operating systems do not follow this β€œhint” and will still use the routing table.

+7
source

You mean something like this:

 Socket socket1 = new Socket(); socket1.bind(new InetSocketAddress("10.1.1.1", port)); socket1.connect(new InetSocketAddress("10.1.3.1", port)); Socket socket2 = new Socket(); socket2.bind(new InetSocketAddress("10.1.2.1", port)); socket2.connect(new InetSocketAddress("10.1.3.1", port); 
+1
source

Source: https://habr.com/ru/post/920413/


All Articles