How can I bind an (outbound, of course) HttpUrlConnection to a specific local ip address, when I have multiple NIC on my client machine?

后端 未结 3 1234
梦谈多话
梦谈多话 2021-01-06 06:28

I have a kind of Http-Gateway app, which acts as an http client towards servers outside our local network.

There is going to be a network configuration upgrade, and

3条回答
  •  被撕碎了的回忆
    2021-01-06 06:52

    You can't. HttpURLConnection doesn't provide any interface to manipulate the socket.

    You shouldn't do this either. Selection of interface is based on routing decision. If you have to manually select the NIC to get to the destination, all your internet connection would have the same issue. You should add static route in the OS to make sure the correct interface is used for the destination.

提交回复
热议问题