在java TCP连接中绑定一个接口 [英] Bind an interface in java TCP connection

查看:29
本文介绍了在java TCP连接中绑定一个接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在solaris 主机中有两个接口.我想通过两个接口向单个 TCP 服务器发起两个 TCP 连接,如图所示.Java中是否有任何选项可以将接口绑定到TCP套接字以覆盖本地路由表?

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 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.

谢谢,

推荐答案

可以使用

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

然而,许多操作系统不尊重这个提示",无论如何都会使用路由表.

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

这篇关于在java TCP连接中绑定一个接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆