Closed gancarani closed 1 year ago
You can override the way that a client creates the socket using setSocketFactory
method. Creating a socket bound to a specific interface should be possible using the 4 argument Socket constructor: https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html#Socket-java.net.InetAddress-int-java.net.InetAddress-int- although I haven't tested this
Thanks, is there somewhere an example on how to do that in the library documents?
There is a similar example in Issue962Test.java in the test directory. It shows how to subclass SocketFactory to return sockets bound to a particular address.
Also read this issue, i think it is related to your use case: #814
Closing as solution is provided and no activity
I have 1 LocalMachine with 2 NIC (NIC1, NIC2), on the same machine I run my java LocalApplication with 2 websocket client (WC1, WC2) running in parallel, those 2 threads are connected to 2 different websocket servers (WS1, WS2) to consume data.
What I would like to do is to bind on single local websocket client to 1 NIC, so to have the following configuration:
LocalMachine->LocalApplication->WC1.bind(NIC1).connectRemoteServer(WS1) LocalMachine->LocalApplication->WC2.bind(NIC2).connectRemoteServer(WS2)
The goal is to use both NICs to read in parallel data from 2 different websocket and improve the performance of the application.