/// <summary> /// Test the specified server /// </summary> /// <param name="activeServer"> /// The server /// </param> /// <exception cref="Exception"> /// Failed to connect to the server or server response is invalid /// </exception> public void TestServer(ServerType activeServer) { try { activeServer = activeServer.Clone(); activeServer.Establish( "google.com", 80, new ProxyClient(null, this), Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\n\r\n")); int timeout = 25000; while (timeout != 0) { Thread.Sleep(100); if (activeServer.ParentClient.LastError != string.Empty) { throw new Exception(activeServer.ParentClient.LastError); } if (activeServer.IsServerValid) { return; } if (activeServer.ParentClient.IsClosed) { throw new Exception("Connection dropped by server."); } timeout -= 100; } throw new Exception("No acceptable response."); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }