Example #1
0
 public static void StopServer()
 {
     try
     {
         _testingProvider = null;
         _tcpListener.Stop();
         _servetThread.Abort();
         _isStarted = false;
         _servetThread.Join();
         _servetThread    = null;
         _testingProvider = null;
         _tcpListener     = null;
     }
     catch { }
     GC.Collect();
 }
Example #2
0
 public static void StartServer(TestingProvider provider)
 {
     _allowConnections = true;
     _serverNotStarted = new ManualResetEvent(true);
     _testingProvider  = provider;
     _port             = GetRandomPort();
     _secureId         = Guid.NewGuid().ToString();
     _servetThread     = new Thread(new ThreadStart(() =>
     {
         StartTcpListener();
         _isStarted = true;
         _serverNotStarted.Set();
         while (true)
         {
             try
             {
                 Socket clientSocket = _tcpListener.AcceptSocket();
                 if (clientSocket.Connected)
                 {
                     if (!_allowConnections)
                     {
                         clientSocket.Close();
                         clientSocket = null;
                         continue;
                     }
                     SystemStateManager.State   = true;
                     ConnectionProcessor server = new ConnectionProcessor(clientSocket);
                     server.StartRead();
                 }
             }
             catch (SocketException)
             { StopServer(); }
         }
     }));
     _servetThread.Start();
 }
Example #3
0
 public HttpHandler(TestingProvider provider)
 {
     _provider = provider;
 }