コード例 #1
0
 public void TestTcpTestServerVerification()
 {
     using (TcpTestServer testserver = new TcpTestServer())
     {
         //Simply verify our TcpTestServer is working without external influence.
         TcpTestServer.Test(testserver.HostName, testserver.Port, 10, 50, 500, 5000, 50000, 500000);
     }
 }
コード例 #2
0
        public void TestSingleForward()
        {
            using (TcpTestServer testserver = new TcpTestServer())
            {
                TunnelConfig config = new TunnelConfig();
                AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

                using (config.Start())
                {
                    //Send to the serverPort, forwards to testserver.Port
                    TcpTestServer.Test(LoopBack, ServerPort, 10, 50, 500, 5000, 50000, 500000);
                }
            }
        }
コード例 #3
0
        public void TestChainForward()
        {
            using (TcpTestServer testserver = new TcpTestServer())
            {
                string       loopback = IPAddress.Loopback.ToString();
                TunnelConfig config   = new TunnelConfig();
                AddClient(config);
                AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

                using (config.Start())
                {
                    //Send to the clientPort, forwards to serverPort, forwards to testserver.Port
                    TcpTestServer.Test(loopback, _clientPort, 10, 50, 500, 5000, 50000, 500000);
                }
            }
        }
コード例 #4
0
        public void TestConcurrentChainForward()
        {
            using (TcpTestServer testserver = new TcpTestServer())
            {
                string       loopback = IPAddress.Loopback.ToString();
                TunnelConfig config   = new TunnelConfig();
                AddClient(config);
                AddServer(config, new IPEndPoint(IPAddress.Loopback, testserver.Port));

                using (config.Start())
                {
                    int nCompleted          = 0;
                    ManualResetEvent mreGO  = new ManualResetEvent(false);
                    ThreadStart      tstart = new ThreadStart(
                        delegate()
                    {
                        mreGO.WaitOne();
                        TcpTestServer.Test(loopback, _clientPort, 10, 50, 500, 5000, 50000, 500000);
                        Interlocked.Increment(ref nCompleted);
                    }
                        );

                    Thread[] threads = new Thread[5];
                    for (int i = 0; i < threads.Length; i++)
                    {
                        threads[i]      = new Thread(tstart);
                        threads[i].Name = String.Format("TcpTestClient({0})", i);
                        threads[i].Start();
                    }

                    Thread.Sleep(100);
                    mreGO.Set();

                    foreach (Thread t in threads)
                    {
                        t.Join();
                    }

                    Assert.AreEqual(threads.Length, nCompleted);
                }
            }
        }