0

this may be a stupid question since I am completely new to Windows Phone development - I've got some experience with developing in C# though... Anyways, I cannot figure out what is going on and MSDN is confusing me, maybe I got it all wrong.

I am simply trying to send UDP datagrams from a Lumia 925 to my PC, so I created an empty Windows Phone 8.1 app via VS wizard (MSVS 2015). Now, MSDN says there's supposed to be a socket class for Windows Phone 8.1, but there isn't even a Sockets namespace in System.Net. Now I tried my luck with DatagramSockets, which, according to MSDN, should feature a method GetEndpointPairsAsync, but it doesn't.

I thought maybe I'm missing assemblies I'd have to add to the References, but in the Add References dialog, there is hardly anything to be found. I'm starting to think that I missed out something very fundamental.

I'd appreciate any ideas.

iko79
  • 1,127
  • 10
  • 23

1 Answers1

1

Yes, you need use Windows.Networking.Sockets instead of System.Net.Sockets. (Reference)

As for GetEndpointPairsAsync() you may try this:

    async Task ListEndpoints()
    {
        HostName host = new HostName("www.stackoverflow.com");
        var eps = await DatagramSocket.GetEndpointPairsAsync(host, "80");
        foreach (EndpointPair ep in eps)
        {
            System.Diagnostics.Debug.WriteLine("EP {0} {1}", new object[] { ep.LocalHostName, ep.RemoteHostName });
        }
    }

More information is here.

Community
  • 1
  • 1
Rita Han
  • 9,574
  • 1
  • 11
  • 24
  • So is this a mistake in MSDN? After all, it clearly says "Namespace: System.Net.Sockets" as well as "Version Information: Windows Phone OS; Supported in: 8.1, 8.0, 7.1; Platforms: Windows Phone". – iko79 Jul 28 '16 at 12:07
  • @iko79 Note its organization structure of the document. [Windows Phone Silverlight development](https://msdn.microsoft.com/en-us/library/windows/apps/ff402535(v=vs.105).aspx)->Windows Phone API reference->.NET API for Windows Phone->System.Net.Sockets->Socket Class. So socket class in your question is for Windows Phone Silverlight. But you created a Windows Runtime project by selecting "Blank App" listed first. You may need select "Blank App(Windows Phone Silverlight)". – Rita Han Jul 29 '16 at 06:16