'How to choose a network in a java program that performs udp exchange in Multicast mode

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?



Solution 1:[1]

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:

  1. Open up Network and Sharing Center
    • Click 'Change Adapter Settings'
    • Right click 'VirtualBox Host-Only Network', go to Properties
  2. Double click "Internet Protocol Version 4 (TCP/IPv4)' under 'This connection uses the following items'.
  3. In the Properties page, click "Advanced..."
  4. In the "Advanced TCP/IP Settings", tab "IP Settings", uncheck the box marked "Automatic Metic" and type in 800 or higher.

Solution 2:[2]

When you declare a variable as LOCAL in crystal reports, the scope of the variable is limited to the function or formula field it is declared within.

Try declaring your variables as SHARED instead if you want to share their values between the main report and the subreport. There is also a GLOBAL scope as well, but it only allows the values to be shared within the local report, leaving your subreport out of scope for the variable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 alexmntmnk
Solution 2 R. McMillan