是否可以指定 JVM(或 IDE)使用哪个网络接口 [英] Is it possible to specify which network interface for a JVM ( or IDE ) to use

查看:18
本文介绍了是否可以指定 JVM(或 IDE)使用哪个网络接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况是这样的,我的 macbook pro 中有两个网络接口.一个是静态定义的以太网接口,另一个是DHCP配置的无线接口.

The situation goes like this, I have two network interfaces in my macbook pro. One is a statically defined Ethernet interface and the other one is a DHCP configured wireless interface.

我试图弄清楚如何配置特定的 java 项目以仅使用我的静态连接接口,而不是简单地通过 JVM 或通过我的 IDEA (IntelliJ 8) 选择列表中的第一个

I am trying to figure out how to configure a specific java project to use my statically wired interface only and not simply pick the first one in the list either through the JVM or through my IDEA ( IntelliJ 8 )

我设法通过一个 vmware 实例实现了这一点,在该实例中,我的虚拟环境仅通过有线接口供电,但此广告性能问题以及在 windows/osx 之间切换的一般性头痛.

I have managed to achieve this via an instance of vmware where I have my virtual environment feeding off my wired interface only but this ads performance problems and just general headaches of flipping between windows / osx.

到目前为止,我一直无法找到让我指定使用哪个 nic 的 jvm 属性,也没有看到定义它的 IntelliJ 文档.如果有人对如何尽可能轻松地解决此问题有任何想法,我将不胜感激.

I have so far been unable to find a jvm property that let's me specify which nic gets used nor have I seen documentation for IntelliJ that defines that. If anyone has any ideas on how to solve this as painlessly as possible I would appreciate the help.

推荐答案

可以,可以通过以下方式指定:

Yes, you can specify by following way:

int port= 52000; //some free port

MulticastSocket msocket = new MulticastSocket(port);

msocket.setInterface(InetAddress.getByName("172.16.30.205"));

其中 172.16.30.205 是我电脑的 IP 地址之一,我想通过接口进行通信.

Where 172.16.30.205 is one of my PC's IP address and I would like to communicate through interface.

这篇关于是否可以指定 JVM(或 IDE)使用哪个网络接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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