Is it possible to use a BinaryReader and BinaryWriter at the same time with the same underlying NetworkStream
- using a single thread sequentially interlacing reads and writes?
- using 1 thread for reading and 1 thread for writing?
(My goal is to simultaneously send and receive data via a TcpClient connection)
So far I've come across two related posts:
One references the NetworkStream docs:
Read and write operations can be performed simultaneously on an instance of the NetworkStream class without the need for synchronization. As long as there is one unique thread for the write operations and one unique thread for the read operations, there will be no cross-interference between read and write threads and no synchronization is required.
The second references the BinaryReader docs:
Using the underlying stream while reading or while using the BinaryReader can cause data loss and corruption. For example, the same bytes might be read more than once, bytes might be skipped, or character reading might become unpredictable.
I'm not 100% sure how to interpret these quotes and I'm not sure which of my 2 cases above are possible if any.