asio icon indicating copy to clipboard operation
asio copied to clipboard

Multicast UDP server fails to receive unicast UDP packages

Open robiwano opened this issue 3 years ago • 6 comments

Using the multicast example server, I can get it to receive messages sent to the multicast group. But if I send direct UDP messages to ip_address:30001, the server doesn't receive anything. I'm pretty sure this is supposed to work? Using version 1.22.1.

robiwano avatar May 09 '22 08:05 robiwano

It depends on the bind of the server socket.

kiwixz avatar May 20 '22 08:05 kiwixz

The bind is on 0.0.0.0:30001 here https://github.com/chriskohlhoff/asio/blob/master/asio/src/examples/cpp11/multicast/receiver.cpp#L27

robiwano avatar May 20 '22 09:05 robiwano

If I send UDP to multicast_ip:30001, it is received. But if I send to 192.168.16.173:30001 (example ip), nothing is received.

robiwano avatar May 20 '22 09:05 robiwano

This should work, I'd launch up wireshark or something to make sure the packets properly arrive to the machine.

kiwixz avatar May 20 '22 09:05 kiwixz

Ok, this is weird. Just retried it (running sender/receiver on same machine) and it works just as expected... ./sender 239.255.0.1 ./sender 127.0.0.1 ./sender 192.168.1.219 all works. Mind you, I just tested in Linux (Ubuntu 18.04), but I've mostly experienced problems on Windows. I'll have to check this.

robiwano avatar May 20 '22 11:05 robiwano

Ok. This is odd. With port number 1900 (instead of 30001) I get the problem, but not with f.i. 1901. 1900 is the port number used for UPnP multicast search. Why would that port number be special?

Can it be that another application has opened port 1900 in non-reuse mode?

robiwano avatar May 20 '22 14:05 robiwano