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

查看:190
本文介绍了在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天全站免登陆