First off I want to be clear that I am not referring to simulcasting a TCP/IP stream, I want to take the output of a c# stream and have it go to multiple destations.
For example if I had a FileStream(fs) and a MemoryStream(ms) and a FtpStream(ftps) and did something like
...
SuperStreamWriter ss = new SuperStreamWriter(fs, ms, ftps);
ss.Write(helloWorld, 0, helloWorld.length);
}
class SuperStreamWriter : Stream
{
Stream[] _s;
public SuperStreamWriter(params Stream[] s)
{
_s = s;
}
public override void Write(byte[] buffer, int offset, int count)
{
foreach (Stream s in _s)
{
s.Write(buffer, offset, count);
}
}
//Other functions cut for example
}
Hello world would be pushed out to all three of my streams. Does anyone know of anything that will give me similar functionality to what I am describing other using that foreach loop on the buffer? Also if the foreach loop is my only/best option would it be safe to thread each iteration of the foreach loop as is?