1
votes

I've implemented the sample code given in this thread. It works a treat as promised. Unfortunately, it will only report back the direct responses to the M-SEARCH request, but nothing else. I'm looking for a way to just listen to the SSDP broadcasts, in order to capture other application's search or notify broadcasts.

I've tried all sorts of configurations with TIdUDPServer, but none was successful. I'm getting to the point where I consider that it might not be possible.

I'm running Win 8.1 with Network Discovery enabled and a MediaServer on another computer on the same network. Firewall on or off doesn't make any difference. Using Window's API for UPnP works as expected and applications using UPnP are detecting the MediaServer and other UPnP devices properly.

Does Window's built-in UPnP service capture those broadcasts on 239:255:255:250:1900 and doesn't pass them on? How can I just listen to those broadcasts?

1
SSDP is not broadcast, it's UDP multicast. This means your server needs to join the multicast group before the messages will be delivered (M-SEARCH replies are not multicast so they work). I didn't write this as an answer since I don't know TldUDPServer.Jussi Kukkonen
I think you need to use TIdIPMCastClientJohan
Thanks jiu. See the answer below. I guess, I cannot listen to the broadcasts and send my own discovery ssdp with the same instance of the server class, right? This will have to be split into two instances, one for the listener, one for the discovery requests and their answers, right?Carsten

1 Answers

1
votes

jku pointed me in the right direction. The TIdUDPServer class provides a AddMulticastMembership method, which does the trick. Thanks jku!

Below the code that works:

var
  server : TIdUDPServer;

...

with server do
  Active := false;
  BroadcastEnabled := true;
  DefaultPort := 1900;
  Binding.IP := GStack.LocalAddress;
  Binding.AddMulticastMembership('239.255.255.250');
  active := true;
end;

I was messing about with all sorts of configurations and tests until I noticed that my firewall has blacklisted something. Still need to figure out what it was, but turning the FW off for the tests certainly helped. Resetting my router, too. Apart from the localhost stuff I hadn't seen anything and after the router reset all UPnP devices on the network could be seen, again. Wired. More stuff I need to understand ....

Thanks again and regards

Carsten