Streams for full duplex in-proc communication, wrap a WebSocket, split a stream into multiple channels, etc.
$ dotnet add package Nerdbank.StreamsEnhanced streams for communication in-proc or across the Internet.
SimplexStream is meant to allow two parties to communicate one direction.
Anything written to the stream can subsequently be read from it. You can share this Stream
with any two parties (in the same AppDomain) and one can send messages to the other.FullDuplexStream creates a pair of bidirectional streams for
in-proc two-way communication; it also creates a single bidirectional stream from two
unidirectional streams.MultiplexingStream allows 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 a WebSocket, System.IO.Pipelines.PipeReader,
System.IO.Pipelines.PipeWriter, or System.IO.Pipelines.IDuplexPipe with a
System.IO.Stream for reading and/or writing.UsePipe() enables reading from
and writing to a Stream or WebSocket using the PipeReader and PipeWriter APIs.Stream.ReadSlice(long) creates a sub-stream that ends after
a given number of bytes.PipeReader.ReadSlice(long) creates a sub-PipeReader that ends after
a given number of bytes.MonitoringStream wraps another Stream and raises events for
all I/O calls so you can monitor and/or trace the data as it goes by.WriteSubstream and ReadSubstream allow 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 for ReadOnlySequence<T>.PrefixingBufferWriter<T> wraps another IBufferWriter<T>
to allow for prefixing some header to the next written buffer, which may be arbitrarily long.BufferTextWriter is a TextWriter-derived type that can
write directly to any IBufferWriter<byte>, making it more reusable than StreamWriter
and thus allows for alloc-free writing across many writers.SequenceTextReader is a TextReader-derived type that can
read directly from any ReadOnlySequence<byte>, making it more reusable than StreamReader
and thus allows for alloc-free reading across many sequences.DuplexPipe is a trivial implementation of IDuplexPipe.Stream.ReadBlockAsync guarantees to fill the supplied buffer except under certain documented conditions, instead of the regular ReadAsync guarantee of supplying at least 1 byte.