These are chat archives for rdavisau/sockets-for-pcl

19th
May 2016
1iveowl
@1iveowl
May 19 2016 12:22
I'm trying to use the "multicast UDP client" to listen to multicasts on ip 239.255.255.250 on port 1900 (UPnP multicasts). Unfortunately on Windows the MS SSDP Service is already listening on port 1900 and I get an "Only One Usage of each Socket Address" exception. Does anyone know of a work-around here? Stopping the MS SSPD Service is not an option. I've tried to listen on another port, but then the multicast UDP packets are not picked up.
Ryan Davis
@rdavisau
May 19 2016 14:33
non-well known ports should be fine for UDP multicast - could there be a network or firewall restriction preventing your traffic on other ports from being picked up?
or are you not in control of sender?
1iveowl
@1iveowl
May 19 2016 15:37
Thanks. No I'm not in control of sender. Sender is any UPnP device in the network sending on 239.255.255.250:1900. Port 1900 mandatory the what I understand the UPnP spec. I've tried to disable the Windows Firewall and listen to port 0 (i.e. auto select a port). It will not pick up UDP packages send to port 1900. I've tried with a test client setting both the received and the test client to broadcast on port 8000. This works, but it does not really help mere here because the UPnP spec dictates port 1900. I know it's possible somehow. This library does it: https://github.com/Yortw/RSSDP However, I've yet to figure out how.
Ryan Davis
@rdavisau
May 19 2016 22:17
i'm not familiar with the SSDP protocol, but looking over the RSSDP code it looks like you should not be required to bind to 1900; you can send the message while bound to any local port and the response will be sent to you there. They outline the same thing here (https://github.com/Yortw/RSSDP/blob/8b2cb95ebabfe27d55d7777579d98beb0098c6a3/src/Main/RSSDP.Portable/SsdpCommunicationsServer.cs#L19-L34) . Unfortunately, sockets-for-pcl currently assumes that when you join a multicast group (address + port), you want to bind to that port and send to it (https://github.com/rdavisau/sockets-for-pcl/blob/959300f3c6daf63e6a7c07c7c8e9d4fa399012c2/Sockets/Sockets.Implementation.NET/UdpSocketMulticastClient.cs#L86-L92), where in this case you'd need those to be controlled independently. The fix is to add an optional port parameter, so you can (for example) bind to 0 and send to 1900. You can open an issue for this
again not being familiar with the SSDP protocol, I'm not sure how important it is that you as the discoverer actually join the group - you may be able to use a UdpSocketReceiver and send to 239.255.255.250:1900 while bound to an arbitrary local port.. similar to this NTP example https://github.com/MitchMilam/NTPClient/blob/master/Demo-NTP/Demo_NTP/NTPClient.cs
1iveowl
@1iveowl
May 19 2016 23:12
Thank you Ryan for a detailed answer. Much appreciated. I've opened an issue: rdavisau/sockets-for-pcl#85 and then I saw your answer here. I've done some debugging on RSSDP and it does actually listen on 1900 too, but maybe as you suggest it does not send there as specified in the comment in the RSSDP code. I've also spoken with the developer: https://github.com/Yortw/RSSDP/issues/20#issuecomment-220455441. Anyhow, it's past 1 AM here. I'll look more into it tomorrow.