/// <summary>
        /// Starts the synchronous authentication process.
        /// </summary>
        /// <exception cref="ProxyException">Authentication with the proxy server failed.</exception>
        /// <exception cref="ProtocolViolationException">The proxy server uses an invalid protocol.</exception>
        /// <exception cref="SocketException">An operating system error occurs while accessing the Socket.</exception>
        /// <exception cref="ObjectDisposedException">The Socket has been closed.</exception>
        private void Authenticate()
        {
            Server.Send(new byte [] { 5, 2, 0, 2 });
            byte[] buffer = ReadBytes(2);
            if (buffer[1] == 255)
            {
                throw new ProxyException("No authentication method accepted.");
            }
            AuthMethod authenticate;

            switch (buffer[1])
            {
            case 0:
                authenticate = new AuthNone(Server);
                break;

            case 2:
                authenticate = new AuthUserPass(Server, Username, Password);
                break;

            default:
                throw new ProtocolViolationException();
            }
            authenticate.Authenticate();
        }
 /// <summary>
 /// Starts the synchronous authentication process.
 /// </summary>
 /// <exception cref="ProxyException">Authentication with the proxy server failed.</exception>
 /// <exception cref="ProtocolViolationException">The proxy server uses an invalid protocol.</exception>
 /// <exception cref="SocketException">An operating system error occurs while accessing the Socket.</exception>
 /// <exception cref="ObjectDisposedException">The Socket has been closed.</exception>
 private void Authenticate()
 {
     Server.Send(new byte [] {5, 2, 0, 2});
     byte[] buffer = ReadBytes(2);
     if (buffer[1] == 255)
         throw new ProxyException("No authentication method accepted.");
     AuthMethod authenticate;
     switch (buffer[1]) {
         case 0:
             authenticate = new AuthNone(Server);
             break;
         case 2:
             authenticate = new AuthUserPass(Server, Username, Password);
             break;
         default:
             throw new ProtocolViolationException();
     }
     authenticate.Authenticate();
 }