如何在Java程序中选择网络,该程序以多播模式执行UDP交换
Java应用程序通过另一台计算机在多播模式下通过UDP传输数据。 VirtualBox安装在同一台计算机上。
这是发送数据的代码:
private final static String IP_ADDR = "224.1.1.201";
DatagramSocket socket;
public void sending() {
socket = new DatagramSocket();
group = InetAddress.getByName(IP_ADDR);
sendingDataBuffer = parserData(dataBuffer);
DatagramPacket packet
= new DatagramPacket(sendingDataBuffer, sendingDataBuffer.length, group, SERVICE_PORT);
socket.send(packet);
}
事实证明,该程序将数据包发送到VirtualBox网络,因此我既不能在接收方接收它们,也无法在Wireshark中看到它们。如何在Java代码中指定哪个网络将数据包发送到? 如果我断开VirtualBox网络连接的连接,则可以通过标准网络连接发送到另一台计算机来发送数据包。
为什么我的应用程序将数据发送到此特定网络?
A Java application transmits data over UDP in Multicast mode with another computer. VirtualBox is installed on the same machine.
Here is the code for sending data:
private final static String IP_ADDR = "224.1.1.201";
DatagramSocket socket;
public void sending() {
socket = new DatagramSocket();
group = InetAddress.getByName(IP_ADDR);
sendingDataBuffer = parserData(dataBuffer);
DatagramPacket packet
= new DatagramPacket(sendingDataBuffer, sendingDataBuffer.length, group, SERVICE_PORT);
socket.send(packet);
}
The problem turned out to be that the program was sending packets to the VirtualBox network, so I could neither receive them on the receiving side nor see them in Wireshark. How can I specify in the Java code which network to send packets to?
If I disconnect the VirtualBox network connection, then packets start to be sent via a standard network connection to another computer.
Why is my app sending data to this particular network?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题源于Microsoft基于Windows 7中驾驶员自己报告的链接速度分配接口指标。由于这是全部1GB,因此公制上有一场冲突。
这是帮助我的解决方案:
The problem stems from Microsoft assigning interface Metrics based on the driver's own reported Link speed in Windows 7. Since that's all 1GB, there is a clash on metric.
Here is the solution that helped me: