I'm currently using System.IO.Pipelines to build a client-server application. Once each client starts, it should request the server to provide some configuration so it will know what to do. The current situation is the System.IO.Pipelines works in async mode which means the client send request to the server and not waiting for response back. The server gets the client's request in the background, process it and send the response, the client get the response in the background and present it on the screen.
I would like to create a mechanism where the client would wait for the server response before it continues. My current solution is based on:
https://github.com/davidfowl/TcpEcho
and
https://github.com/gfoidl/TcpEcho
Would appreciate to have your assistance achieving it while keep using Pipelines (I know I can do it with a simple buffer but I do want to enjoy the advantage of the pipelines library)
You can use
PipeReader.TryRead()
to read synchronously from a pipeline.https://learn.microsoft.com/en-us/dotnet/api/system.io.pipelines.pipereader.tryread?view=dotnet-plat-ext-5.0