Esempio n. 1
0
        private void SocketPong(bool useTls, int bytesPerIteration, int readBufferSize)
        {
            _clientsComplete     = 0;
            _firstAsyncException = null;
            _testComplete        = new ManualResetEvent(false);

            ArrayList        clients = new ArrayList();
            SocketPongServer server  = new SocketPongServer(useTls, readBufferSize, CertFile, PvkFile, PvkPassword);

            server.ExceptionOccurred += new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);

            server.Start();

            try
            {
                for (int i = 0; i < TotalClients; i++)
                {
                    if (_testComplete.WaitOne(0, false))
                    {
                        break;
                    }

                    SocketPingClient client = new SocketPingClient(useTls, server.LocalEndPoint, SendIterations, bytesPerIteration, readBufferSize);
                    client.ExceptionOccurred += new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);
                    client.TestComplete      += new SocketPingClient.TestCompleteEventHandler(this.TestCompleteCallback);
                    client.Start();
                }

                if (TestTimeoutMs <= 0)
                {
                    _testComplete.WaitOne();
                }
                else
                {
                    if (!_testComplete.WaitOne(TestTimeoutMs, false))
                    {
                        Assert.Fail("Tests timed out");
                    }
                }

                if (null != _firstAsyncException)
                {
                    Assert.Fail(_firstAsyncException.ToString());
                }
            }
            finally
            {
                if (ClientInitiatedClose)
                {
                    CloseClients(clients);
                }

                server.ExceptionOccurred -= new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);
                server.Stop();

                if (!ClientInitiatedClose)
                {
                    CloseClients(clients);
                }
            }
        }
Esempio n. 2
0
		private void SocketPong(bool useTls, int bytesPerIteration, int readBufferSize)
		{
			_clientsComplete = 0;
			_firstAsyncException = null;
			_testComplete = new ManualResetEvent(false);

			ArrayList clients = new ArrayList();
			SocketPongServer server = new SocketPongServer(useTls, readBufferSize, CertFile, PvkFile, PvkPassword);
			server.ExceptionOccurred += new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);

			server.Start();

			try
			{
				for (int i = 0; i < TotalClients; i++)
				{
					if (_testComplete.WaitOne(0, false))
						break;

					SocketPingClient client = new SocketPingClient(useTls, server.LocalEndPoint, SendIterations, bytesPerIteration, readBufferSize);
					client.ExceptionOccurred += new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);
					client.TestComplete += new SocketPingClient.TestCompleteEventHandler(this.TestCompleteCallback);
					client.Start();
				}

				if (TestTimeoutMs <= 0)
					_testComplete.WaitOne();
				else
				{
					if (!_testComplete.WaitOne(TestTimeoutMs, false))
						Assert.Fail("Tests timed out");
				}

				if (null != _firstAsyncException)
					Assert.Fail(_firstAsyncException.ToString());
			}
			finally
			{
				if (ClientInitiatedClose)
					CloseClients(clients);

				server.ExceptionOccurred -= new AsyncTestClassBase.ExceptionOccurredEventHandler(this.ExceptionCallback);
				server.Stop();

				if (!ClientInitiatedClose)
					CloseClients(clients);
				
			}
		}