wstream 2.1.1
See the version list below for details.
dotnet add package wstream --version 2.1.1
NuGet\Install-Package wstream -Version 2.1.1
<PackageReference Include="wstream" Version="2.1.1" />
paket add wstream --version 2.1.1
#r "nuget: wstream, 2.1.1"
// Install wstream as a Cake Addin #addin nuget:?package=wstream&version=2.1.1 // Install wstream as a Cake Tool #tool nuget:?package=wstream&version=2.1.1
WStream - WebSocket Streams
WStream offers a simple and high-performance WebSocket stream built on top of Kestrel
Use Cases:
- Server-to-Server communication.
- Sending binary data through web proxies like Cloudflare.
- Building custom protocols.
- Writing micro websocket servers without too much boilerplate.
- Bypassing TCP filters through a firewall.
Wow, that sounds great! How do I use WStream?
Usage
WStream offers three main constructs, WsClient
, WsServer
and WsStream
.
Here is a simple example of a ping program built in WStream.
// create the server
var server = new WsServer();
await server.StartAsync(new IPEndPoint(IPAddress.Any, 8080), async stream =>
{
// called when a client connects
await stream.WriteAsync(BitConverter.GetBytes(DateTime.Now.ToBinary()));
await stream.CloseAsync();
});
// start client
var client = new WsClient();
var connection = await client.ConnectAsync(new Uri("ws://localhost:8080"));
// read data
var binReader = new BinaryReader(connection);
Console.WriteLine($"Current time is {DateTime.FromBinary(binReader.ReadInt64())}");
// cleanup
client.Dispose();
server.Dispose();
Advanced Usage
WStream also supports extending the existing stream. You are able to overload the underlying websocket with custom behaviour like compression or encryption.
An example usage of this API is shown in the samples
project.
Performance
WStream was built with performance in mind.
Here is a benchmark performed on Windows 10 Build 19402 with a core i7-6700k and 32gb of system ram.
Buffer Size: 65536 Throughput: 558.92 MBps Elapsed: 00:15:16.0470650 Message Rate: 8,942.77 msg/s Payload Size: 511,999.00 MB.
As you can see, WStream reaches over 4 Gbps through a single connection!
Current Limitations
Due to the fact that Kestrel is bundled inside of ASP.NET Core, there are a large number of dependencies. There is currently no way around this 😦
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- Microsoft.AspNetCore.Server.Kestrel (>= 2.2.0)
- Microsoft.AspNetCore.WebSockets (>= 2.2.1)
- System.IO.Pipelines (>= 5.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on wstream:
Package | Downloads |
---|---|
wstream.Crypto
Provides experimental crypto for wstream |
GitHub repositories
This package is not used by any popular GitHub repositories.