1
votes

I want to check if data is avaiable on the UDP multicast address, the only mechanism I found was the Poll method.

Setup:

client = new UdpClient(localEp);
client.JoinMulticastGroup(multicastAddr, localIpAddress);
client.Connect(multicastAddr, receiveport);

Polling:

if (!client.Client.Poll(100, SelectMode.SelectRead))

The client is connected (I checked) but never returns true.
In wireshark I can see the udp datagrams are sent correctly.

Suggestions for fixes?

Edit:

IPEndpoint localEp = local ipv4 unicast address, port for multicast udps receiveport = port for receiving multicasts multicastaddr = IPAddress

1

1 Answers

0
votes

Connecting UDP socket means restricting datagram source address and port to the specified pair when receiving, and setting default destination address and port when sending.

Remove call to Connect().

Edit 0:

You need to bind to the multicast address, not the local IP. Either remove localEp from the constructor, or replace it with pair of the multicast group/port. See examples on MSDN.

And you are wrong, you can Receive() just one datagram.