Orspace.TcpServer
1.0.2
dotnet add package Orspace.TcpServer --version 1.0.2
NuGet\Install-Package Orspace.TcpServer -Version 1.0.2
<PackageReference Include="Orspace.TcpServer" Version="1.0.2" />
<PackageVersion Include="Orspace.TcpServer" Version="1.0.2" />
<PackageReference Include="Orspace.TcpServer" />
paket add Orspace.TcpServer --version 1.0.2
#r "nuget: Orspace.TcpServer, 1.0.2"
#:package Orspace.TcpServer@1.0.2
#addin nuget:?package=Orspace.TcpServer&version=1.0.2
#tool nuget:?package=Orspace.TcpServer&version=1.0.2
Orspace.TcpServer
A simple Tcp Server to handle client connections using asynchronous apis for scalability and high performance.
Designed to work with the .NET generic host model to enable features like dependency injection, logging and app configuration loading.
Server Configuration
The server is configured through the project appsettings.json.
An example of the configuration file is shown below.
<img src="configuration.jpg" width="350"/>
Request Handler
Handle incoming request by implementing the IConnectionHandler interface. This interface contains a single method signature.
Register the concrete class with the dependency injection container (as a transient object) to hook it up with the server. A helper method AddMessageHandler is provided to assist with this.
Returning from this method signals an end of the connection and the server disposes of the passed in Tcpclient instance.
Make use of the passed in cancellationtoken to gracefully terminate any on going connections to avoid forceful termination by the server. There is no need to dispose of the TcpClient instance as this is handled by the server.
If you need to do some object clean up in your Handler class, implement IDisposable or its asynchronous counterpart IAsyncDisposable
and the server will call either Dispose() or DisposeAsync() to run your clean up code.
Example Usage
Refer to the project Orspace.TcpServer.Example for an example implementation of the IConnectionHandler interface.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Hosting (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated Connectionhandler instance creation to handle proper disposable and object resolution