TcpFrame 1.0.12
See the version list below for details.
dotnet add package TcpFrame --version 1.0.12
NuGet\Install-Package TcpFrame -Version 1.0.12
<PackageReference Include="TcpFrame" Version="1.0.12" />
paket add TcpFrame --version 1.0.12
#r "nuget: TcpFrame, 1.0.12"
// Install TcpFrame as a Cake Addin #addin nuget:?package=TcpFrame&version=1.0.12 // Install TcpFrame as a Cake Tool #tool nuget:?package=TcpFrame&version=1.0.12
TcpFrame C# Library
TcpFrame is a C# library that provides event-driven TCP framing capabilities. It simplifies the process of handling framed data over TCP connections, allowing you to focus on processing the received frames.
Installation
Search for the nuget TcpFrame
and add it to your project.
Alternatively, via the CLI dotnet add package TcpFrame
Usage
Check the examples folder for a working example.
Client
var tcpFrame = new TcpFrameClient();
await tcpFrame.ConnectAsync();
Client Advanced (Optional ILogger)
var tcpFrame = new TcpFrameClient(logger)
{
Host = "127.0.0.1",
Port = 9000,
AutoReconnect = true,
ReconnectDelay = 1000,
ReconnectInitialDelay = 0,
Config = new Configuration
{
EventLoopGroup = new MultithreadEventLoopGroup(),
Shared = new Configuration.General
{
ByteOrder = ByteOrder.BigEndian,
LengthFieldLength = 4,
LengthAdjustment = 0
},
Encoder = new Configuration.Encoding
{
LengthFieldIncludesLengthFieldLength = false
},
Decoder = new Configuration.Decoding
{
MaxFrameLength = 8 * 1_024 * 1_024,
LengthFieldOffset = 0,
InitialBytesToStrip = 4,
FailFast = false
}
}
};
await tcpFrame.ConnectAsync();
Server
var tcpFrame = new TcpFrameServer();
await tcpFrame.StartAsync();
Server Advanced (Optional ILogger)
var tcpFrame = new TcpFrameClient(logger)
{
Port = 9000,
Config = new Configuration
{
EventLoopGroup = new MultithreadEventLoopGroup(),
Shared = new Configuration.General
{
ByteOrder = ByteOrder.BigEndian,
LengthFieldLength = 4,
LengthAdjustment = 0
},
Encoder = new Configuration.Encoding
{
LengthFieldIncludesLengthFieldLength = false
},
Decoder = new Configuration.Decoding
{
MaxFrameLength = 8 * 1_024 * 1_024,
LengthFieldOffset = 0,
InitialBytesToStrip = 4,
FailFast = false
}
}
};
await tcpFrame.StartAsync();
Rust - Tokio Framing Interop
I wrote this wrapper for DotNetty so I could communicate with my rust service that utilizes framing. The defaults of TcpFrame suits tokio framing with the defaults.
Code fragment for Rust
use tokio::net::TcpStream;
use tokio_util::codec::{Framed, LengthDelimitedCodec};
// stream and tokio spawn code for handling clients was redacted for brevity
fn create_framed_socket(stream: TcpStream) -> Framed<TcpStream, LengthDelimitedCodec> {
// Default settings
let codec = LengthDelimitedCodec::new();
// Default settings (Expanded)
let codec = LengthDelimitedCodec::builder()
.max_frame_length(8 * 1_024 * 1_024)
.length_field_offset(0)
.length_field_length(4)
.length_adjustment(0)
.big_endian()
.new_codec();
// Create the framed stream
Framed::new(stream, codec)
}
You can use this with MessagePack serialization, which allows you to interop between MessagePack (CSharp) and MessagePack (Rust). As a side note, rust handles its enums as arrays compared to dotnet which handles it as an integer type, so you will need to deal with that in your code, either at the dotnet side or the rust side. I opted to handle it at the rust side.
Contributing
Contributions to TcpFrame are welcome! If you find any issues or have ideas for improvements, please open an issue or submit a pull request on the Github repository: https://github.com/mbwilding/TcpFrame.
When contributing, please follow the existing code style and conventions. Additionally, make sure to thoroughly test your changes and provide appropriate documentation.
License
TcpFrame is distributed under the MIT License. See the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- DotNetty.Codecs (>= 0.7.5)
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
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.27 | 194 | 11/22/2023 |
1.0.26 | 116 | 11/22/2023 |
1.0.25 | 117 | 11/21/2023 |
1.0.24 | 112 | 11/21/2023 |
1.0.23 | 159 | 8/12/2023 |
1.0.22 | 139 | 8/12/2023 |
1.0.21 | 165 | 8/12/2023 |
1.0.20 | 162 | 8/12/2023 |
1.0.19 | 166 | 8/11/2023 |
1.0.18 | 158 | 5/29/2023 |
1.0.17 | 141 | 5/29/2023 |
1.0.16 | 141 | 5/28/2023 |
1.0.15 | 147 | 5/28/2023 |
1.0.14 | 145 | 5/28/2023 |
1.0.13 | 135 | 5/28/2023 |
1.0.12 | 150 | 5/28/2023 |
1.0.11 | 146 | 5/28/2023 |
1.0.10 | 134 | 5/28/2023 |
1.0.9 | 140 | 5/28/2023 |