Nerdbank.Streams
v2.12.74-alphaPre-release
net8.0.NETStandard2.0.NETStandard2.1
Streams for full duplex in-proc communication, wrap a WebSocket, split a stream into multiple channels, etc.
Published
Mar 3, 2025
1y ago
Total Downloads
43.1M
43,095,339
Install
dotnet add package Nerdbank.Streams --version 2.12.74-alpha
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard |
README
Specialized .NET Stream classes
Enhanced streams for communication in-proc or across the Internet.
Features
SimplexStreamis meant to allow two parties to communicate one direction. Anything written to the stream can subsequently be read from it. You can share thisStreamwith any two parties (in the same AppDomain) and one can send messages to the other.FullDuplexStreamcreates a pair of bidirectional streams for in-proc two-way communication; it also creates a single bidirectional stream from two unidirectional streams.MultiplexingStreamallows you to split any bidirectional .NET Stream into many sub-streams (called channels). This allows two parties to establish just one transport stream (e.g. named pipe or web socket) and use it for many independent protocols. For example, one might set up JSON-RPC on one channel and use other channels for efficient binary transfers.AsStream()wraps aWebSocket,System.IO.Pipelines.PipeReader,System.IO.Pipelines.PipeWriter, orSystem.IO.Pipelines.IDuplexPipewith aSystem.IO.Streamfor reading and/or writing.UsePipe()enables reading from and writing to aStreamorWebSocketusing thePipeReaderandPipeWriterAPIs.Stream.ReadSlice(long)creates a sub-stream that ends after a given number of bytes.PipeReader.ReadSlice(long)creates a sub-PipeReaderthat ends after a given number of bytes.MonitoringStreamwraps another Stream and raises events for all I/O calls so you can monitor and/or trace the data as it goes by.WriteSubstreamandReadSubstreamallow you to serialize data of an unknown length as part of a larger stream, and later deserialize it such in reading the substream, you cannot read more bytes than were written to it.Sequence<T>is a builder forReadOnlySequence<T>.PrefixingBufferWriter<T>wraps anotherIBufferWriter<T>to allow for prefixing some header to the next written buffer, which may be arbitrarily long.BufferTextWriteris aTextWriter-derived type that can write directly to anyIBufferWriter<byte>, making it more reusable thanStreamWriterand thus allows for alloc-free writing across many writers.SequenceTextReaderis aTextReader-derived type that can read directly from anyReadOnlySequence<byte>, making it more reusable thanStreamReaderand thus allows for alloc-free reading across many sequences.DuplexPipeis a trivial implementation ofIDuplexPipe.Stream.ReadBlockAsyncguarantees to fill the supplied buffer except under certain documented conditions, instead of the regularReadAsyncguarantee of supplying at least 1 byte.
Changes from Previous Version
v2.11.92v2.12.74-alpha
Added Frameworks
net8.0
Removed Frameworks
net6.0
Added Dependencies
Microsoft.VisualStudio.Threading(net8.0)
System.IO.Pipelines(net8.0)
Microsoft.VisualStudio.Threading(.NETStandard2.0)
Microsoft.VisualStudio.Threading(.NETStandard2.1)
Removed Dependencies
System.IO.Pipelines(net6.0)
Microsoft.Bcl.AsyncInterfaces(net6.0)
Microsoft.VisualStudio.Threading.Only(.NETStandard2.0)
Microsoft.VisualStudio.Threading.Only(.NETStandard2.1)
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.The published metadata declares 13 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.