Thoughts on how I might read 1 stream and write it to many others?

I have a network stream incoming on one thread. I want to forward that data to potentially many clients.

Right now I have I have a thread that listens for clients and adds their stream to a collection that the server an just loop over and forward the data to.

Works great with 1 client, but when the 2nd client shows up the data is no longer right. I don't quite understand it, it's as if the buffer gets out of sync even though I'm not making another read on the stream until I've written to all the outgoing streams.

I assume I'm just doing this wrong so looking for suggestions. Google hasn't been much help

by cod3r__ via /r/csharp

Leave a Reply