locked
Allow multiple apps to receive UPnP datagram traffic RRS feed

  • Question

  • I'm seeing that its apparently not possible on WinRT for more than one app on a machine to bind a datagram socket to the local IP and a given port.

    For UPnP its essential to listen on port 1900 for UPnP traffic generated by networked devices.

    I basically create a new DatagramSocket and simply call BindEndpointAsync(null,"1900"); then call JoinMulticastGroup("239.255.255.250");

    The bind though fails if another app is running that has also executed these steps.

    Is there an alternative way for multiple apps to receive these broadcast datagrams?

    Here is another thread which more clearly explains my situation.

    Thx

    Cap'n



    Friday, October 25, 2013 5:41 PM

All replies

  • I'm seeing a solution to this - basically there is no need to bind the socket or join multicast groups in the way I am doing. Instead I can just create the DatagramSocket and then use the GetOutputStreamAsync to send a message to 239.255.255.250,1900 - a short time later replies come back to the MessageReceived handler - I can run umpteen apps like this and they all work fine.

    Here is the code I studied to get this running.

    Problem is I don't quite understand this - my understanding has been that we must join a multicast group and so on to receive these broadcast messages but this technique doesn't do that yet it works...

    I'll explore the ramifications of this tomorrow - perhaps I misread the UPnP spec or something but any input from others here is welcome.

    Cap'n

    Friday, October 25, 2013 8:55 PM
  • OK I can see the drawback here - the above code handles only unicast replies to the sent SSDP search messages, hence we never receive UPnP "advertisements".

    These messages are sent whenever a device is added to the network or switched on after being off - the above code never sees these but the multicast listener (that I already use) does because its actively listening for multicast traffic.

    So my original question in my OP above still stands...

    Cap'n

    Friday, October 25, 2013 9:10 PM