简体   繁体   中英

Why must StreamSocketListener be used in UWP instead of TcpListener, although UWP is a subset of .NET Core and TcpListener is available in UWP?

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://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=netcore-1.0 ) the class is available starting from .NET Core 1.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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM