1. 程式人生 > >Asp.net Core 2.1 Kestrel 現在支援 多協議處理(Tcp)

Asp.net Core 2.1 Kestrel 現在支援 多協議處理(Tcp)

地址:https://github.com/davidfowl/MultiProtocolAspNetCore.git

在一個Kestrel服務上可以同時處理Tcp,Http,Https等多種協議。

通過實現 ConnectionHandler 處理接入連線,ConnectionContext.Transport 實現System.IO.Piplines 中的介面IDuplexPipe 。

WebHost.CreateDefaultBuilder 時設定下就行。

 

.UseKestrel(options =>

                {

                    
// TCP 8007 options.ListenLocalhost(8007, builder => { builder.UseConnectionHandler<MyEchoConnectionHandler>(); }); // HTTP 5000 options.ListenLocalhost(5000);
// HTTPS 5001 options.ListenLocalhost(5001, builder => { builder.UseHttps(); }); })


 

Kestrel 的演進目標現在開來是要做一個通用的伺服器。