Answered by:
DatagramSocket MessageReceived event is not firing, a simple multicast receiver

Question
-
I am developing a windows universal app and need to use ssdp discovery on a multicast. I am not able to create a listener using DataGramSocket. My code is simple and straight forward.
ConnectionProfile netProfile = NetworkInformation.GetInternetConnectionProfile();
DatagramSocket socket = new DatagramSocket();
socket.MessageReceived += socket_MessageReceived;
await socket.BinddServiceNameAsync("",netProfile.NetworkAdapter);
socket.JoinMulticastGroup(new HostName("239.255.255.250"));
string message = "NOTIFY * HTTP /1.1 \r\n" +....
var stream = await socket.GetOutputStreamAsync(new HostName("239.255.255.250"), "1900");
var writer = new DataWriter(stream);
var data = Encoding.UTF8.GetBytes(message);
writer.WriteBytes(data);
await writer.StoreAsync();
async void socket_MessageReceived(DataSocket sender, DatagramSocketMessageReceivedEventArgs args)
{
/// reading logic.
}
I could see message write is happening successfully and the peer device is responding with multiple response messages. I could see all these happening through wireshark. But my "messagereceived" event is not firing.
Then I created a simple receiver with UdpClient on the same windows 8 machine which works perfectly fine on receiving all ssdp messages.
Can somebody point out what am I doing wrong or is there a simple UdpClient available for window phone 8.1?
Regards,
JJ
Tuesday, January 27, 2015 9:23 PM
Answers
-
The server continuously receives datagram packets over a datagram socket. Each datagram packet received by the server indicates a client request for a quotation. When the server receives a datagram, it replies by sending a datagram packet that contains a one-line "quote of the moment" back to the client.
The client application in this example is fairly simple. It sends a single datagram packet to the server indicating that the client would like to receive a quote of the moment. The client then waits for the server to send a datagram packet in response.
Two classes implement the server application:
QuoteServer
andQuoteServerThread
. A single class implements the client application:QuoteClient
- Proposed as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 1:40 AM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 9:06 AM
Thursday, January 29, 2015 3:31 AM
All replies
-
or if anybody has a ssdp discovery working sample code in windows phone 8.1 that would be really helpful. I found lot of samples over internet using DatagramSocket with multiple versions.. all of them has exact same problem.
I am almost struck so any help is really appreciated.
- Edited by Jijo Jose Wednesday, January 28, 2015 6:17 PM
Wednesday, January 28, 2015 12:32 PM -
Jeff,
I have created this thread yesterday with my issue discretion.
NB: Just replying to your request for new thread in the other link
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/bc77d405-90fc-476c-8c12-d3208d455680/ssdp-discovery-on-windows-store-app-not-reliable?forum=winappswithcsharp
Wednesday, January 28, 2015 6:35 PM -
The server continuously receives datagram packets over a datagram socket. Each datagram packet received by the server indicates a client request for a quotation. When the server receives a datagram, it replies by sending a datagram packet that contains a one-line "quote of the moment" back to the client.
The client application in this example is fairly simple. It sends a single datagram packet to the server indicating that the client would like to receive a quote of the moment. The client then waits for the server to send a datagram packet in response.
Two classes implement the server application:
QuoteServer
andQuoteServerThread
. A single class implements the client application:QuoteClient
- Proposed as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 1:40 AM
- Marked as answer by Herro wongMicrosoft contingent staff Tuesday, February 10, 2015 9:06 AM
Thursday, January 29, 2015 3:31 AM