finds.dev← search

// the find

davidfowl/TcpEcho

★ 374 · C# · MIT · updated Mar 2021

Basic TCP server that uses System.IO.Pipelines to parse line based messages

A minimal reference implementation showing how to wire System.IO.Pipelines to a TCP socket for line-delimited message parsing. Written by David Fowl (ASP.NET team lead), so it reflects the intended usage pattern directly from the people who designed the API. It is a teaching sample, not a library.

Pipelines backpressure handling is demonstrated correctly — the reader loop properly awaits `FlushAsync` and checks `IsCompleted`, which most handwritten examples get wrong. The `SocketExtensions` wrapping is clean and shows exactly how to bridge a `Socket` to `PipeWriter`/`PipeReader` without leaking abstractions. Comes with both client and server, so you can actually run it and see the protocol in action. Authoritative source — if you want to know how pipelines should be used for network IO, this is closer to the spec than any blog post.

Last touched in 2021 and has no mention of `System.Net.Sockets.SocketAsyncEventArgs` or the newer `Socket.ReceiveAsync(Memory<byte>)` overloads that reduce allocations further. No TLS support and no pointer toward how you'd add it (the answer is `SslStream` + `PipeReader.AsStream()`, but you're on your own). The error handling is bare — socket disconnects and partial writes are handled just enough to not crash the demo, not enough to copy into production. Zero tests.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →