I have two iMacs sitting together on the same network. One is older and running Mojave the other is new and running Catalina. Both are using Java 8 and both are listening to the same multicast channels. The old one receives the multicasts fine, the new one does not.
tcpdump shows that the packets are being received on the new machine but the java multicast listener is not showing them.
Here is the java multicast listener code:
import java.io.*;
import java.net.*;
public class MulticastListenerBare {
public MulticastListenerBare(String ip, int port) {
try {
InetAddress group = InetAddress.getByName(ip);
MulticastSocket sin = new MulticastSocket(port);
sin.joinGroup(group);
byte[] buf = new byte[64*1024];
DatagramPacket pin = new DatagramPacket(buf, buf.length,
group, port);
System.out.printf("Listening to %s : %d\n", ip, port);
while (true) {
sin.receive(pin);
String data = new String(buf, 0, pin.getLength());
System.out.println("Received: \n" + data);
}
}catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}catch (Throwable t) {
System.out.println("Unknown Throwable happened: " + t.getMessage());
}
}//constructor
public static void main(String[] args) {
if(args.length != 2) {
System.out.println
("usage: java -Djava.net.preferIPv4Stack=true " +
"MulticastListener ip port\n");
System.exit(-1);
}
try {
int port = Integer.parseInt(args[1]);
new MulticastListenerBare(args[0], port);
}catch(NumberFormatException e) {
System.out.println("error parsing port #: '" + args[1] + "'");
}
}//main
}//MulticastListenerBare
Under Catalina's system preferences 'Security & Privacy', I have granted full disk access to both java and terminal.
The program is run from the terminal like this:
java -Djava.net.preferIPv4Stack=true MulticastListenerBare 239.192.2.25 52025
Any ideas as to why it is not picking up the multicasts?