Can TPL Dataflow be used for processing a TCP byte stream? I'm fairly new to this topic and am looking for the best way to process a TCP byte stream.
To be more specific: I'm using a protocol (HSMS) on top of TCP/IP which specifies messages with 4 length bytes and a message structure. I'm writing a library and have a consumer who receives the decoded messages. What I need to do in my library is:
- read the bytes from the Socket and buffer them
- as soon as I have the length bytes and the message itself I need to transform/decode it.
- then I'll pass the message to the consumer of the library
Usually I have one producer and one consumer. And the IO operations are asynchronous.
I started doing it all manually but realized that it's quite complex and tedious, especially with thread safety. So I stumbled upon TPL dataflow and am curious if it's worth considering for this case. My main concern is that I have only one producer (Socket) and one consumer and wonder if it's overkill.
I also found System.IO.Pipelines but also there is not much information for my use case.