DatagramSocket event MessageReceived dosen't t

2019-09-05 02:13发布

问题:

I have a Console Udp Server based on the System.Net.Sockets UdpClient from which I'm sending Udp Packets to the Ip of my Windows Phone 8.1.

The client on the phone uses Windows.Networking.Sockets DatagramSocket, my problem is that the event MessageReceived dosen't happen.

Source for DatagramSocket:https://msdn.microsoft.com/library/windows/apps/br241319

回答1:

Took me ages to find the solution since it's pretty dumb: The DatagramSocket only starts to receive after it has sent something. (At least for broadcast messages.)

Some code: https://gist.github.com/michaelosthege/857acac92b8ee689a6bb30d5bf23d9f6