[英]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.