public static byte[] ToByteArray(PipePacket[] pipes) { BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream()) { formatter.Serialize(stream, pipes); stream.Seek(0, SeekOrigin.Begin); return stream.ToArray(); } }
static void Main(string[] args) { PipePacket[] pipes = new PipePacket[2] { new PipePacket(), new PipePacket() }; MappedDataFile manager = new MappedDataFile(); TCPServer server = new TCPServer(); while (true) { manager.Write(pipes); Thread.Sleep(5000); } }
public void Write(PipePacket[] packets) { communicator.Write(PipePacket.ToByteArray(packets)); Console.WriteLine("Wrote packet..."); }