繁体   English   中英

为什么在 UWP 中必须使用 StreamSocketListener 而不是 TcpListener,尽管 UWP 是 .NET Core 的子集,并且 TcpListener 在 UWP 中可用?

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

如此此处所述,在 UWP 中不可能使用 TcpListener。 相反,必须使用 StreamSocketListener。

但是经过比较长时间的研究,我不明白为什么?

由于 UWP 实际上是 .NET Core 的一个子集,因此在 UWP 中也应该可以使用 TcpListener!

只是为了测试,我什至创建了一个UWP项目,尝试在代码中使用System.Net.Sockets.TcpListener,没有问题。 我没有编写完整的代码,也没有尝试运行服务器,只是尝试从 UWP 项目中引用 System.Net.Sockets.TcpListener,这是可能的。 这也难怪,因为即使根据 Microsoft 文档( https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcplistener?view=netcore-1.0 ),该类也可以从 .NET 开始使用核心 1.0。

较新版本的 UWP 支持 .NET Standard 2.0,其中包括许多在较早版本的 UWP 中不可用的 API。

参见例如: https : //devblogs.microsoft.com/dotnet/annoucing-uwp-support-for-net-standard-2-0/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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