Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidfowl/multiprotocolaspnetcore
https://github.com/davidfowl/multiprotocolaspnetcore
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/davidfowl/multiprotocolaspnetcore
- Owner: davidfowl
- Created: 2018-07-18T08:42:40.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-10T21:26:11.000Z (almost 6 years ago)
- Last Synced: 2024-11-09T03:58:18.678Z (about 1 month ago)
- Language: C#
- Size: 7.81 KB
- Stars: 253
- Watchers: 16
- Forks: 32
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Multi-protocol Server with ASP.NET Core and Kestrel
The following sample shows how you can host a TCP server and HTTP server in the same ASP.NET Core application. The TCP server runs on port 8007 and the HTTP server runs on ports 5000 and 5001.
Under the covers, it's the same server (Kestrel) running different protocols on different ports. The [ConnectionHandler](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.connections.connectionhandler?view=aspnetcore-2.1) is a new primitive introduced in ASP.NET Core 2.1 to support non-HTTP protocols. ConnectionHandlers are activated by the dependency injection system in ASP.NET Core; this means you can access any registered service in the constructor of your `ConnectionHandler`.
ConnectionHandlers also provide access to the connected client via a [ConnectionContext](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.connections.connectioncontext?view=aspnetcore-2.1). The `ConnectionContext` provides information about the underlying connection (like the connection id) and it also exposes the raw data stream using an `IDuplexPipe`. The `IDuplexPipe` is a new primitive that represents a bi-directional stream using the new [System.IO.Pipelines](https://blogs.msdn.microsoft.com/dotnet/2018/07/09/system-io-pipelines-high-performance-io-in-net/) library.
## What is this really?
This is part of a larger effort called Bedrock. You can read more about it [here](https://github.com/aspnet/KestrelHttpServer/issues/1980).