java tcp接口,在Java TCP连接中绑定接口

在Java中,可以通过指定本地接口来创建Socket连接,尝试利用多个网络接口连接TCP服务器。然而,某些操作系统可能不遵循此设置,仍会使用路由表。可以使用`new Socket(hostname, port, localInterface, 0)`来尝试绑定接口,但效果可能因操作系统而异。
摘要由CSDN通过智能技术生成

I have two interfaces in a solaris host. I would like to initiate two TCP connections to a single TCP server via both interfaces as shown in the diagram. Are there any options in Java to bind the interface to the TCP socket to override the local routing table?

I am attaching the network diagram,

I9h6O.jpg

I would like to use both the serial links bandwidth to get the data from server. Hence I would like to initiate the connection on both the interfaces.

thanks,

解决方案

You can use

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

However, many OSes do not honour this "hint" and will use the routing table anyway.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值