I am trying to get a multicast UDP receiver working in a windows form in c#
I have found the following code online
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,ProtocolType.Udp);
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 2237);
s.Bind(ipep);
IPAddress ip = IPAddress.Parse("239.255.0.1");
s.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.AddMembership,new MulticastOption(ip, IPAddress.Any));
byte[] b = new byte[1024];
s.Receive(b);
string str = System.Text.Encoding.ASCII.GetString(b, 0, b.Length);
Console.WriteLine(str.Trim());
Which from what I have read should work. My problem is I get the following error
"An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Additional information: Only one usage of each socket address (protocol/network address/port) is normally permitted"
This error is generated at the line
s.Bind(ipep);
The multicast IP address and port are controlled by other software, which is already working NOT written by me, and UDP packet is already being received by 2 other programs also NOT written by me
This is out of my area of knowledge if anyone can help I would be grateful
Thanks David