private void AAAA() { while (IsRun) { try { byte[] buff = ci.Read(12); if (buff.Length != 12) { throw new Exception("Pipe Read Length Error"); } ulong transportHeader = BitConverter.ToUInt64(buff, 0); if (transportHeader != 0x1122334455667788u) { throw new Exception("Pipe Read TransportHeader Error"); } uint transportLength = BitConverter.ToUInt32(buff, 8); buff = ci.Read(transportLength); if (buff.Length != transportLength) { throw new Exception("Pipe Read TransportLength Error"); } var str = Encoding.UTF8.GetString(buff, 1, buff.Length - 1); if (buff[0] == 1) { Console.Write(str); } else { Console.Write("Server failure:" + str); } } catch { } } ci.Close(); }
public void TestPipeIO() { PipeClient client; Thread thread; string value; client = new PipeClient(); thread = new Thread(() => OpenPipeServer("PipeTest")); thread.Start(); client.Connect("PipeTest"); client.Write("1"); value = client.Read(); Assert.AreEqual(1, Int32.Parse(value), "Pipe communication failed."); client.Close(); }
public override byte[] ReceiveDatas() { return(PC.Read(8192)); }