Пример #1
0
        /// <summary>
        /// Attempts to establish the connection with the remote server
        /// </summary>
        private void Connect()
        {
            const int BUF_SZ = 65536;

            _conn = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _conn.ReceiveBufferSize = BUF_SZ;
            _conn.SendBufferSize    = BUF_SZ;

            //establish a socket connection
            _conn.Connect(_hostName, _port);

            //read the auth challenge packet to be sent by the server
            AuthChallenge challenge = new AuthChallenge(_conn);

            //construct and send a response
            AuthResponse response = new AuthResponse(challenge, _password);

            response.Send(_conn);

            //check our status
            AuthStatus status = new AuthStatus(_conn);

            if (status.Status != AuthStatus.StatusType.AS_SUCCESS)
            {
                throw new AuthException("Authentication failed, bad password");
            }
        }
Пример #2
0
        /// <summary>
        /// Attempts to establish the connection with the remote server
        /// </summary>
        private void Connect()
        {
            const int BUF_SZ = 65536;
            _conn = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _conn.ReceiveBufferSize = BUF_SZ;
            _conn.SendBufferSize = BUF_SZ;

            //establish a socket connection
            _conn.Connect(_hostName, _port);

            //read the auth challenge packet to be sent by the server
            AuthChallenge challenge = new AuthChallenge(_conn);

            //construct and send a response
            AuthResponse response = new AuthResponse(challenge, _password);
            response.Send(_conn);

            //check our status
            AuthStatus status = new AuthStatus(_conn);
            if (status.Status != AuthStatus.StatusType.AS_SUCCESS)
            {
                throw new AuthException("Authentication failed, bad password");
            }
        }