Ejemplo n.º 1
0
        public void TestReadString()
        {
            string target = "This is a short message";
            Task   server = Task.Run(() =>
            {
                pipe.WaitForConnection();
                Assert.AreEqual(target, protocol.ReadString());
            });

            using (Stream client = CreateClient())
            {
                PipeUtilities.SendStringToPipe(client, target);
            }

            server.Wait();
        }
Ejemplo n.º 2
0
        public void TestReadString()
        {
            string target = "This is a short message";
            Task   server = Task.Run(() =>
            {
                pipe.WaitForConnection();
                Assert.AreEqual(target, protocol.ReadString());
            });
            Socket client = CreateClient();

            byte[] buf = Encoding.Default.GetBytes(target);
            client.Send(BitConverter.GetBytes(buf.Length).Take(4).ToArray());
            // sock.Send(new byte[23] { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x20, 0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65 });
            client.Send(buf);
            client.Disconnect(false);

            server.Wait();
        }