Beispiel #1
0
        public void PingPong()
        {
            var server = new PingPongServer();
            var client = new PingPongClint(server.LocalEndPoint);

            byte[] ping = new UTF8Encoding(true).GetBytes("ping");
            IList <ArraySegment <byte> > sendBuffer       = new List <ArraySegment <byte> >();
            ArraySegment <byte>          pingArraySegment = new ArraySegment <byte>(ping, 0, ping.Length);

            sendBuffer.Add(pingArraySegment);
            client.Send(sendBuffer);
            lock (testLock)
            {
                while (serverResult == null || clientResult == null)
                {
                    Monitor.Wait(testLock);
                }
            }
            Assert.AreEqual(serverResult, "ping");
            Assert.AreEqual(clientResult, "pong");
            client.ShutDown();
            server.Clear();
        }
Beispiel #2
0
 public void PingPong()
 {
     var server = new PingPongServer();
     var client = new PingPongClint(server.LocalEndPoint);
     byte[] ping = new UTF8Encoding(true).GetBytes("ping");
     IList<ArraySegment<byte>> sendBuffer = new List<ArraySegment<byte>>();
     ArraySegment<byte> pingArraySegment = new ArraySegment<byte>(ping, 0, ping.Length);
     sendBuffer.Add(pingArraySegment);
     client.Send(sendBuffer);
     lock (testLock)
     {
         while (serverResult == null || clientResult == null)
         {
             Monitor.Wait(testLock);
         }
     }
     Assert.AreEqual(serverResult, "ping");
     Assert.AreEqual(clientResult, "pong");
     client.ShutDown();
     server.Clear();
 }