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

查看:140
本文介绍了是否可以指定要使用的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; //一些免费端口

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天全站免登陆