Orspace.TcpServer 1.0.2

dotnet add package Orspace.TcpServer --version 1.0.2
                    
NuGet\Install-Package Orspace.TcpServer -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Orspace.TcpServer" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Orspace.TcpServer" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Orspace.TcpServer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Orspace.TcpServer --version 1.0.2
                    
#r "nuget: Orspace.TcpServer, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Orspace.TcpServer@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Orspace.TcpServer&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Orspace.TcpServer&version=1.0.2
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 596 8/6/2022
1.0.1 593 5/6/2022
1.0.0 558 5/6/2022

Updated Connectionhandler instance creation to handle proper disposable and object resolution