UDP Multicast does not work as expected [Answered]
I am starting to play around with UDP for some IPC stuff and wrote a simple UDP Multicast application just to have a playground to advance from, but sadly its not going as expected.
First of all: here is the code of the small program https://gist.github.com/cap5lut/ce3bfda6a0997b647a67a20d78d9e189
My expectation was that the writer sends the data and both readers would receive the data, resulting in an output like
but that is not the case, only the writer and reader 1 is spitting out stuff.
what am I doing wrong?
9 Replies
Its possible the 2nd reader isnt being scheduled. Async/await isnt necessarily going to provide concurrency. Try using threads or manually created long running tasks
it is already using task.whenall
Thats not necessarily going to start all three tasks
in my case with multiple serialports it does
Async/await is intended for i/o
This code isnt i/o
just added some more logs, seems the 2nd reader is stuck on
socket.Bind(new IPEndPoint(IPAddress.Any, MulticastPort));
its throwing System.Net.Sockets.SocketException (10048)
but now i still dont understand how i would make that worksocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
did the job, thanks for ur help!✅ This post has been marked as answered!