0

As mentioned here and here, the usage of TcpListener ist not possible in UWP. Instead, StreamSocketListener has to be used.

But after a relatively long research, I didn't understand why?

Since UWP is actually a subset of of .NET Core, using TcpListener should be possible in UWP also!

Just for testing, I even created a UWP project, tried to use System.Net.Sockets.TcpListener in the code and there was no problem. I didn't write the complete code and didn't try to run the server, but only tried to reference System.Net.Sockets.TcpListener from within a UWP project and this was possible. And no wonder because even according to Microsoft docs (https://learn.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=netcore-1.0) the class is available starting from .NET Core 1.0.

user9514066
  • 119
  • 1
  • 11
  • "UWP is actually a subset of of .NET Core" is another typical misunderstanding. Though UWP/.NET Core shares many common pieces, they are different target platforms, and that's why only .NET Standard bridges them together. – Lex Li Dec 13 '19 at 22:04
  • Oh! so is this picture wrong https://i.stack.imgur.com/nl9gf.png ? – user9514066 Dec 13 '19 at 22:28
  • You might refer to latest diagrams such as https://devblogs.microsoft.com/dotnet/introducing-net-5/ You shouldn't expect a diagram to always tell all the truth, because the author might just be loo lazy to draw a separate rectangle for UWP. – Lex Li Dec 13 '19 at 22:35
  • Well, actually I didn't depend only on the diagram, I ran into the diagram in this answer here: https://stackoverflow.com/a/53531324/9514066 where the guy is saying explicitly that UWP is subset of .NET Core and he is using the diagram on purpose to illustrate his point – user9514066 Dec 13 '19 at 23:03
  • Then clearly that answer has been challenged immediately to be misleading, and Microsoft no longer uses such diagrams in their later official blog posts. – Lex Li Dec 13 '19 at 23:27

1 Answers1

0

Newer versions of UWP support .NET Standard 2.0, which includes many APIs that were not available in earlier versions of UWP.

See eg: https://devblogs.microsoft.com/dotnet/announcing-uwp-support-for-net-standard-2-0/

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • According to the docs (look at the link I mentioned in my question), TcpListener applies to: .NET Core 1.0. This means, it should be available in all UWP versions – user9514066 Dec 13 '19 at 21:12
  • @user9514066 You misunderstood that page. As you are using UWP, the only applicable item is ".NET Standard", which means if the UWP version your project targets has implemented a certain .NET Standard version, then `TcpListener` should work flawlessly there. – Lex Li Dec 13 '19 at 22:02