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 的演进目标现在开来是要做一个通用的服务器。

   

猜你喜欢

转载自www.cnblogs.com/cerl/p/9924731.html