Multicast in Metro style apps RRS feed

  • Question

  • Hi,

    I understand that the steps by which I can do multicast using DataGramSocket is as follows in c++ Metro style app:

    1. Create the DatagramSocket.
    2 Assign the MessageReceived event to an event handler.
    3 Bind the DatagramSocket to a local service name or UDP port.
    4. Call the GetOutputStreamAsync method to get the OutputStream to send data to the remote endpoint.
     I am trying to do WSD discovery ( Muticast address "" and Service name 3702)using the below code from C++ metro style app:

    m_MySocket = ref new DatagramSocket();
    listenerContext = ref new ListenerContext(rootPage, m_MySocket );// for reply receive purpose. 
    m_MySocket ->MessageReceived += ref new TypedEventHandler<DatagramSocket^, DatagramSocketMessageReceivedEventArgs^>(listenerContext, &ListenerContext::OnMyMessage);

    task<void>(m_MySocket ->BindServiceNameAsync("3702")).then([this] (task<void> previousTask)
          HostName^ MyHostName = ref new HostName("");
         m_Socket->JoinMulticastGroup( MyHost );

         task<IOutputStream^>(m_Socket->GetOutputStreamAsync( MyHostName,"3702")).then([this] ( IOutputStream^ stream )

                   // send udp packet to this muticast address here.


    I hope by the JoinMultiCast function the client is actually participating in the multicast. But having done this, does the client really have to call the GetOutputStreamAsync() using the same multicast address and service name(")? By what all steps can i ensure that i will receive data from a receiver? It would also be nice if someone could point me a good sample for this. I found one at the below link.


    But this is not complete. I am trying to detect network devices that support WSD discovery.

    • Edited by its_me_here Wednesday, July 18, 2012 8:19 PM
    Wednesday, July 18, 2012 8:15 PM


All replies

  • its me here,

    I am looking into this for you.

    Best Wishes - Eric

    Friday, July 20, 2012 1:56 AM
  • Hi,

     I am able to discover network devices now by some modifications in the multicast packet sent to the network. But the thing is, for this discovery to wok, the service Function Discovery Resource Publication needs to be stopped. It wont work while this service is running. Is there any work around?

    • Edited by its_me_here Saturday, July 21, 2012 4:59 AM
    Saturday, July 21, 2012 4:58 AM
  • Its  Me Here,

    There is no workaround.

    Best Wishes - Eric

    Friday, August 3, 2012 12:52 PM
  • hi, not sure if this is an answer but I have reliable managed code running as a store app (phone and surface) that does UPnP discovery using SSDP.

    I wrote everything from scratch and do all of the socket IO and SSDP parsing etc.

    This relies on datagram sockets so I suspect you can do what your asking.


    Friday, September 27, 2013 3:47 AM