当前位置: 首页>>代码示例>>C#>>正文


C# SocketCallBackResult类代码示例

本文整理汇总了C#中SocketCallBackResult的典型用法代码示例。如果您正苦于以下问题:C# SocketCallBackResult类的具体用法?C# SocketCallBackResult怎么用?C# SocketCallBackResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SocketCallBackResult类属于命名空间,在下文中一共展示了SocketCallBackResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadLineCompleted

            private void ReadLineCompleted(SocketCallBackResult result,long count,Exception x,object tag)
            {
                // Accoridng RFC, we should get only "DONE" here.

                if(result == SocketCallBackResult.Ok){
                    if(Encoding.Default.GetString(((MemoryStream)tag).ToArray()).ToUpperInvariant() == "DONE"){
                        // Send "cmd-tag OK IDLE terminated" to connected client.
                        m_pSession.Socket.WriteLine(m_CmdTag + " OK IDLE terminated");

                        m_pSession.BeginRecieveCmd();

                        Dispose();
                    }
                    // Connected client send illegal stuff us, end session.
                    else{
                        m_pSession.EndSession();

                        Dispose();
                    }
                }
                // Receive errors, probably TCP connection broken.
                else{
                    m_pSession.EndSession();

                    Dispose();
                }
            }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:27,代码来源:IMAP_Session.cs

示例2: EndBDatCmd

        private void EndBDatCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        m_BDAT_ReadedCount += count;

                        // BDAT command completed, got all data junks
                        if((bool)tag){
                            // Maximum allowed message size exceeded.
                            if((m_BDAT_ReadedCount) > m_pServer.MaxMessageSize){
                                m_pServer.OnMessageStoringCompleted(this,"Requested mail action aborted: exceeded storage allocation",m_pMsgStream);

                                this.Socket.BeginWriteLine("552 Requested mail action aborted: exceeded storage allocation",new SocketCallBack(this.EndSend));
                            }
                            else{
                                // Notify Message stream owner that message storing completed ok.
                                MessageStoringCompleted_eArgs oArg = m_pServer.OnMessageStoringCompleted(this,null,m_pMsgStream);
                                if(oArg.ServerReply.ErrorReply){
                                    this.Socket.BeginWriteLine(oArg.ServerReply.ToSmtpReply("500","Error storing message"),new SocketCallBack(this.EndSend));
                                }
                                else{
                                    this.Socket.BeginWriteLine(oArg.ServerReply.ToSmtpReply("250","Message(" + m_BDAT_ReadedCount + " bytes) stored ok."),new SocketCallBack(this.EndSend));
                                }
                            }

                            /* RFC 2821 4.1.1.4 DATA
                            NOTE:
                                Receipt of the end of mail data indication requires the server to
                                process the stored mail transaction information.  This processing
                                consumes the information in the reverse-path buffer, the forward-path
                                buffer, and the mail data buffer, and on the completion of this
                                command these buffers are cleared.
                            */
                            ResetState();
                        }
                        // Got BDAT data block, BDAT must continue, that wasn't last data block.
                        else{
                            // Maximum allowed message size exceeded.
                            if((m_BDAT_ReadedCount) > m_pServer.MaxMessageSize){
                                this.Socket.BeginWriteLine("552 Requested mail action aborted: exceeded storage allocation",new SocketCallBack(this.EndSend));
                            }
                            else{
                                this.Socket.BeginWriteLine("250 Data block of " + count + " bytes recieved OK.",new SocketCallBack(this.EndSend));
                            }
                        }
                        break;

                    case SocketCallBackResult.SocketClosed:
                        if(m_pMsgStream != null){
                            // We must call that method to notify Message stream owner to close/dispose that stream.
                            m_pServer.OnMessageStoringCompleted(this,"SocketClosed",m_pMsgStream);
                            m_pMsgStream = null;
                        }
                        // Stream is already closed, probably by the EndSession method, do nothing.
                        //else{
                        //}

                        EndSession();
                        return;

                    case SocketCallBackResult.Exception:
                        if(m_pMsgStream != null){
                            // We must call that method to notify Message stream owner to close/dispose that stream.
                            m_pServer.OnMessageStoringCompleted(this,"Exception: " + exception.Message,m_pMsgStream);
                            m_pMsgStream = null;
                        }
                        // Stream is already closed, probably by the EndSession method, do nothing.
                        //else{
                        //}

                        OnError(exception);
                        return;
                }
            }
            catch(Exception x){
                OnError(x);
            }
        }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:80,代码来源:SMTP_Session.cs

示例3: EndRecieveCmd

        /// <summary>
        /// Is called if command is recieved.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void EndRecieveCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        MemoryStream strm = (MemoryStream)tag;

                        string cmdLine = System.Text.Encoding.Default.GetString(strm.ToArray());

                        // Exceute command
                        if(SwitchCommand(cmdLine)){
                            // Session end, close session
                            EndSession();
                        }
                        break;

                    case SocketCallBackResult.LengthExceeded:
                        this.Socket.WriteLine("500 Line too long.");

                        BeginRecieveCmd();
                        break;

                    case SocketCallBackResult.SocketClosed:
                        EndSession();
                        break;

                    case SocketCallBackResult.Exception:
                        OnError(exception);
                        break;
                }
            }
            catch(ReadException x){
                if(x.ReadReplyCode == ReadReplyCode.LengthExceeded){
                    this.Socket.WriteLine("500 Line too long.");

                    BeginRecieveCmd();
                }
                else if(x.ReadReplyCode == ReadReplyCode.SocketClosed){
                    EndSession();
                }
                else if(x.ReadReplyCode == ReadReplyCode.UnKnownError){
                    OnError(x);
                }
            }
            catch(Exception x){
                 OnError(x);
            }
        }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:56,代码来源:SMTP_Session.cs

示例4: OnDataReadServerResponseFinished

        /// <summary>
        /// Is called when smtp client has finished reading DATA command server response line.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void OnDataReadServerResponseFinished(SocketCallBackResult result,
                                                      long count,
                                                      Exception exception,
                                                      object tag)
        {
            CommadCompleted callback = (CommadCompleted) (((object[]) tag)[1]);

            try
            {
                if (result == SocketCallBackResult.Ok)
                {
                    string responseLine =
                        Encoding.ASCII.GetString(((MemoryStream) (((object[]) tag)[2])).ToArray());

                    // Response line must start with 334 or otherwise it's error response
                    if (!responseLine.StartsWith("354"))
                    {
                        throw new Exception(responseLine);
                    }
                    else
                    {
                        Stream message = (Stream) (((object[]) tag)[0]);

                        // Start sending message to smtp server
                        m_pSocket.BeginWritePeriodTerminated(message, callback, OnDataMessageSendFinished);
                    }
                }
                else
                {
                    HandleSocketError(result, exception);
                }
            }
            catch (Exception x)
            {
                // Pass exception to callback method
                callback(SocketCallBackResult.Exception, x);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:45,代码来源:SmtpClientEx.cs

示例5: OnDataMessageSendReadServerResponseFinished

        /// <summary>
        /// Is called when smtp client has finished reading MESSAGE send smtp server response line.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void OnDataMessageSendReadServerResponseFinished(SocketCallBackResult result,
                                                                 long count,
                                                                 Exception exception,
                                                                 object tag)
        {
            CommadCompleted callback = (CommadCompleted) (((object[]) tag)[0]);

            try
            {
                // TODO: some servers close connection after DATA command, hanndle Socket closed.

                if (result == SocketCallBackResult.Ok)
                {
                    string responseLine =
                        Encoding.ASCII.GetString(((MemoryStream) (((object[]) tag)[1])).ToArray());

                    // Response line must start with 250 or otherwise it's error response
                    if (!responseLine.StartsWith("250"))
                    {
                        throw new Exception(responseLine);
                    }
                    else
                    {
                        // DATA: completed susscessfully, call callback method.
                        callback(SocketCallBackResult.Ok, null);
                    }
                }
                else
                {
                    HandleSocketError(result, exception);
                }
            }
            catch (Exception x)
            {
                // Pass exception to callback method
                callback(SocketCallBackResult.Exception, x);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:45,代码来源:SmtpClientEx.cs

示例6: OnAuthLoginPwdReadServerResponseFinished

        /// <summary>
        /// Is called when smtp client has finished reading AUTH LOGIN password send server response line.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param> 
        private void OnAuthLoginPwdReadServerResponseFinished(SocketCallBackResult result,
                                                              long count,
                                                              Exception exception,
                                                              object tag)
        {
            Auth_state_data stateData = (Auth_state_data) tag;

            try
            {
                if (result == SocketCallBackResult.Ok)
                {
                    string responseLine = Encoding.ASCII.GetString(((MemoryStream) stateData.Tag).ToArray());

                    // Response line must start with 235 or otherwise it's error response
                    if (!responseLine.StartsWith("235"))
                    {
                        throw new Exception(responseLine);
                    }
                    else
                    {
                        m_Authenticated = true;

                        if (m_Authenticated && m_pSocket.Logger != null)
                        {
                            m_pSocket.Logger.UserName = stateData.UserName;
                        }

                        // AUTH LOGIN completed susscessfully, call callback method.
                        stateData.Callback(SocketCallBackResult.Ok, null);
                    }
                }
                else
                {
                    HandleSocketError(result, exception);
                }
            }
            catch (Exception x)
            {
                // Pass exception to callback method
                stateData.Callback(SocketCallBackResult.Exception, x);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:49,代码来源:SmtpClientEx.cs

示例7: OnBdatSendFinished

        /// <summary>
        /// Is called when smtp client has finished BDAT command sending.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void OnBdatSendFinished(SocketCallBackResult result,
                                        long count,
                                        Exception exception,
                                        object tag)
        {
            CommadCompleted callback = (CommadCompleted) (((object[]) tag)[1]);

            try
            {
                if (result == SocketCallBackResult.Ok)
                {
                    // BDAT command successfully sent to SMTP server, start sending DATA.
                    m_pSocket.BeginWrite((Stream) (((object[]) tag)[0]), callback, OnBdatDataSendFinished);
                }
                else
                {
                    HandleSocketError(result, exception);
                }
            }
            catch (Exception x)
            {
                // Pass exception to callback method
                callback(SocketCallBackResult.Exception, x);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:32,代码来源:SmtpClientEx.cs

示例8: OnDataReadServerResponseFinished

		/// <summary>
		/// Is called when smtp client has finished reading DATA command server response line.
		/// </summary>
		/// <param name="result"></param>
		/// <param name="count"></param>
		/// <param name="exception"></param>
		/// <param name="tag"></param>
		private void OnDataReadServerResponseFinished(SocketCallBackResult result,long count,Exception exception,object tag)
		{
			CommadCompleted callback = (CommadCompleted)(((object[])tag)[1]);

			try{
				if(result == SocketCallBackResult.Ok){
					string responseLine = System.Text.Encoding.ASCII.GetString(((MemoryStream)(((object[])tag)[2])).ToArray());

					// Response line must start with 334 or otherwise it's error response
					if(!responseLine.StartsWith("354")){
						throw new Exception(responseLine);
					}
					else{
						Stream message = (Stream)(((object[])tag)[0]);
						message.Seek(0,SeekOrigin.End);

						// Terminate message <CRLF>.<CRLF>
						message.Write(new byte[]{(byte)'\r',(byte)'\n',(byte)'.',(byte)'\r',(byte)'\n'},0,5);

						message.Seek(0,SeekOrigin.Begin);
					
						// Start sending message to smtp server
						m_pSocket.BeginSendData(message,callback,new SocketCallBack(this.OnDataMessageSendFinished));	
					}				
				}
				else{
					HandleSocketError(result,exception);
				}
			}
			catch(Exception x){
				// Pass exception to callback method
				callback(SocketCallBackResult.Exception,x);
			}
		}
开发者ID:sidneylimafilho,项目名称:InfoControl,代码行数:41,代码来源:SmtpClientEx.cs

示例9: HandleSocketError

		/// <summary>
		/// Handles socket errors.
		/// </summary>
		/// <param name="result"></param>
		/// <param name="x"></param>
		private void HandleSocketError(SocketCallBackResult result,Exception x)
		{
			if(result == SocketCallBackResult.Exception){
				throw x;
			}
			else{
				throw new Exception(result.ToString());
			}
		}
开发者ID:sidneylimafilho,项目名称:InfoControl,代码行数:14,代码来源:SmtpClientEx.cs

示例10: EndAppendCmd

        /// <summary>
        /// Is called when DATA command is finnished.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void EndAppendCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                if(m_pServer.LogCommands){
                    m_pLogWriter.AddEntry("big binary " + count.ToString() + " bytes",this.SessionID,this.RemoteEndPoint.Address.ToString(),"S");
                }

                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        Hashtable         param   = (Hashtable)tag;
                        string            cmdTag  = (string)param["cmdTag"];
                        string            mailbox = (string)param["mailbox"];
                        IMAP_MessageFlags mFlags  = (IMAP_MessageFlags)param["mFlags"];
                        DateTime          date    = (DateTime)param["date"];
                        MemoryStream      strm    = (MemoryStream)param["strm"];

                        IMAP_Message msg = new IMAP_Message(null,"",0,mFlags,0,date);
                        string errotText = m_pServer.OnStoreMessage(this,mailbox,msg,strm.ToArray());
                        if(errotText == null){
                            SendData(cmdTag + " OK APPEND completed, recieved " + strm.Length + " bytes\r\n");
                        }
                        else{
                            SendData(cmdTag + " NO " + errotText + "\r\n");
                        }
                        break;

                    case SocketCallBackResult.LengthExceeded:
                    //	SendData("552 Requested mail action aborted: exceeded storage allocation\r\n");

                    //	BeginRecieveCmd();
                        break;

                    case SocketCallBackResult.SocketClosed:
                        EndSession();
                        return;

                    case SocketCallBackResult.Exception:
                        OnError(exception);
                        return;
                }

                // Command completed ok, get next command
                BeginRecieveCmd();
            }
            catch(Exception x){
                OnError(x);
            }
        }
开发者ID:janpoo,项目名称:ProtocolNet,代码行数:56,代码来源:IMAP_Session.cs

示例11: EndRecieveCmd

        /// <summary>
        /// Is called if command is recieved.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="exception"></param>
        /// <param name="count"></param>
        /// <param name="tag"></param>
        private void EndRecieveCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        MemoryStream strm = (MemoryStream)tag;

                        string cmdLine = System.Text.Encoding.Default.GetString(strm.ToArray());

                        if(m_pServer.LogCommands){
                            m_pLogWriter.AddEntry(cmdLine + "<CRLF>",this.SessionID,this.RemoteEndPoint.Address.ToString(),"C");
                        }

                        // Exceute command
                        if(SwitchCommand(cmdLine)){
                            // Session end, close session
                            EndSession();
                        }
                        break;

                    case SocketCallBackResult.LengthExceeded:
                        SendData("-ERR Line too long.\r\n");

                        BeginRecieveCmd();
                        break;

                    case SocketCallBackResult.SocketClosed:
                        EndSession();
                        break;

                    case SocketCallBackResult.Exception:
                        OnError(exception);
                        break;
                }
            }
            catch(Exception x){
                 OnError(x);
            }
        }
开发者ID:janpoo,项目名称:ProtocolNet,代码行数:47,代码来源:POP3_Session.cs

示例12: EndBDatCmd

        private void EndBDatCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        m_BDAT_ReadedCount += count;

                        // BDAT command completed, got all data junks
                        if((bool)tag)
                        {
                            // Maximum allowed message size exceeded.
                            if((m_BDAT_ReadedCount) > m_pServer.MaxMessageSize)
                            {
                                m_pServer.OnMessageStoringCompleted(this,"Requested mail action aborted: exceeded storage allocation",m_pMsgStream);

                                this.Socket.BeginWriteLine("552 Requested mail action aborted: exceeded storage allocation",new SocketCallBack(this.EndSend));
                            }
                            else
                            {
                                // Notify Message stream owner that message storing completed ok

                                if (m_CERT_mode == true && m_CERT_valid == true) // miceli
                                {
                                    string masterkeyprivatefilename = "master.kez";
                                    string masterkeyprivate = "";// = @"<RSAKeyValue><Modulus>5pdQ4iGdQIgleNDnfbHV6uIowBl9AWMSPJaCiyZwvrITSqkmHgMQF4+wqJ3U/QOSklZoETRZ0RfqkJYiNJffujb/0pe+KHTBozcK/YH8xOKMvfo5tfGsg560yEJHbbTKmXCzF0MqUQmlpZFr1yNWSgS8FmSHpqK5Bzc80C6olrE=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
                                    int bitStrength = 1024;
                                    if (File.Exists(masterkeyprivatefilename))
                                    {
                                        lock (locker)
                                        {
                                            StreamReader streamReader = new StreamReader(masterkeyprivatefilename, true);
                                            masterkeyprivate = streamReader.ReadToEnd();
                                            streamReader.Close();
                                        }
                                        string bitStrengthString = masterkeyprivate.Substring(0, masterkeyprivate.IndexOf("</BitStrength>") + 14);
                                        masterkeyprivate = masterkeyprivate.Replace(bitStrengthString, "");
                                        bitStrength = Convert.ToInt32(bitStrengthString.Replace("<BitStrength>", "").Replace("</BitStrength>", ""));
                                    }

                                    string lineRead;
                                    string[] lines;
                                    string headers;

                                    SaveStream(m_pMsgStream, @"c:\predecrypt.txt");

                                    RSACryptoPad.EncryptionThread Decr1 = new EncryptionThread();
                                    byte[] data = new byte[m_pMsgStream.Length];
                                    m_pMsgStream.Position = 0;
                                    m_pMsgStream.Read(data, 0, (int)m_pMsgStream.Length);
                                    lineRead = Encoding.ASCII.GetString(data);
                                    lines = lineRead.Split('\n');
                                    headers = lines[0] + '\n' + lines[1];
                                    string message = Decr1.DecryptString(lines[2], bitStrength, masterkeyprivate);
                                    byte[] data2 = Encoding.ASCII.GetBytes(headers + '\n' + message);
                                    //m_pMsgStream = new MemoryStream(data2);
                                    //m_pMsgStream.Flush();
                                    m_pMsgStream.Write(data2, 0, data2.Length);
                                    //m_pMsgStream.Position = 0;
                                }

                                SaveStream(m_pMsgStream, @"c:\postdecrypt.txt");

                                MessageStoringCompleted_eArgs oArg = m_pServer.OnMessageStoringCompleted(this,null,m_pMsgStream);
                                if(oArg.ServerReply.ErrorReply)
                                {
                                    this.Socket.BeginWriteLine(oArg.ServerReply.ToSmtpReply("500","Error storing message"),new SocketCallBack(this.EndSend));
                                }
                                else{
                                    this.Socket.BeginWriteLine(oArg.ServerReply.ToSmtpReply("250","Message(" + m_BDAT_ReadedCount + " bytes) stored ok."),new SocketCallBack(this.EndSend));
                                }
                            }

                            /* RFC 2821 4.1.1.4 DATA
                            NOTE:
                                Receipt of the end of mail data indication requires the server to
                                process the stored mail transaction information.  This processing
                                consumes the information in the reverse-path buffer, the forward-path
                                buffer, and the mail data buffer, and on the completion of this
                                command these buffers are cleared.
                            */
                            ResetState();
                        }
                        // Got BDAT data block, BDAT must continue, that wasn't last data block.
                        else{
                            // Maximum allowed message size exceeded.
                            if((m_BDAT_ReadedCount) > m_pServer.MaxMessageSize){
                                this.Socket.BeginWriteLine("552 Requested mail action aborted: exceeded storage allocation",new SocketCallBack(this.EndSend));
                            }
                            else{
                                this.Socket.BeginWriteLine("250 Data block of " + count + " bytes recieved OK.",new SocketCallBack(this.EndSend));
                            }
                        }
                        break;

                    case SocketCallBackResult.SocketClosed:
                        if(m_pMsgStream != null){
                            // We must call that method to notify Message stream owner to close/dispose that stream.
                            m_pServer.OnMessageStoringCompleted(this,"SocketClosed",m_pMsgStream);
                            m_pMsgStream = null;
//.........这里部分代码省略.........
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:101,代码来源:SMTP_Session.cs

示例13: EndDataCmd

        /// <summary>
        /// Is called when DATA command is finnished.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void EndDataCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
            //	if(m_pServer.LogCommands){
            //		m_pLogWriter.AddEntry("big binary " + count.ToString() + " bytes",this.SessionID,this.RemoteEndPoint.Address.ToString(),"S");
            //	}

                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        using(MemoryStream msgStream = Core.DoPeriodHandling(m_pMsgStream,false)){
                    //		if(Core.ScanInvalid_CR_or_LF(msgStream)){
                    //			m_pSocket.BeginSendLine("500 Message contains invalid CR or LF combination.",new SocketCallBack(this.EndSend));
                    //		}
                    //		else{
                                m_pMsgStream.SetLength(0);

                                // Store message
                                m_pMsgStream.Position = 0;
                                NewMail_EventArgs oArg = m_pServer.OnStoreMessage(this,msgStream);

                                // There is custom reply text, send it
                                if(oArg.ReplyText.Length > 0){
                                    m_pSocket.BeginSendLine("250 " + oArg.ReplyText,new SocketCallBack(this.EndSend));
                                }
                                else{
                                    m_pSocket.BeginSendLine("250 OK",new SocketCallBack(this.EndSend));
                                }
                    //		}
                        }
                        break;

                    case SocketCallBackResult.LengthExceeded:
                        m_pSocket.BeginSendLine("552 Requested mail action aborted: exceeded storage allocation",new SocketCallBack(this.EndSend));
                        break;

                    case SocketCallBackResult.SocketClosed:
                        EndSession();
                        return;

                    case SocketCallBackResult.Exception:
                        OnError(exception);
                        return;
                }

                /* RFC 2821 4.1.1.4 DATA
                    NOTE:
                        Receipt of the end of mail data indication requires the server to
                        process the stored mail transaction information.  This processing
                        consumes the information in the reverse-path buffer, the forward-path
                        buffer, and the mail data buffer, and on the completion of this
                        command these buffers are cleared.
                */
                ResetState();

                // Command completed ok, get next command
            //	BeginRecieveCmd();
            }
            catch(Exception x){
                OnError(x);
            }
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:69,代码来源:SMTP_Session.cs

示例14: EndDataCmd

        /// <summary>
        /// Is called when DATA command is finnished.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param>
        private void EndDataCmd(SocketCallBackResult result,long count,Exception exception,object tag)
        {
            try{
                if(m_pServer.LogCommands){
                    m_pLogWriter.AddEntry("big binary " + count.ToString() + " bytes",this.SessionID,this.RemoteEndPoint.Address.ToString(),"S");
                }

                switch(result)
                {
                    case SocketCallBackResult.Ok:
                        using(MemoryStream msgStream = Core.DoPeriodHandling(m_pMsgStream,false)){
                            m_pMsgStream.SetLength(0);

                            // Store message
                            m_pServer.OnStoreMessage(this,msgStream);

                            SendData("250 OK\r\n");
                        }
                        break;

                    case SocketCallBackResult.LengthExceeded:
                        SendData("552 Requested mail action aborted: exceeded storage allocation\r\n");

                        BeginRecieveCmd();
                        break;

                    case SocketCallBackResult.SocketClosed:
                        EndSession();
                        return;

                    case SocketCallBackResult.Exception:
                        OnError(exception);
                        return;
                }

                /* RFC 2821 4.1.1.4 DATA
                    NOTE:
                        Receipt of the end of mail data indication requires the server to
                        process the stored mail transaction information.  This processing
                        consumes the information in the reverse-path buffer, the forward-path
                        buffer, and the mail data buffer, and on the completion of this
                        command these buffers are cleared.
                */
                ResetState();

                // Command completed ok, get next command
                BeginRecieveCmd();
            }
            catch(Exception x){
                OnError(x);
            }
        }
开发者ID:janpoo,项目名称:ProtocolNet,代码行数:59,代码来源:SMTP_Session.cs

示例15: OnAuthLoginUserReadServerResponseFinished

        /// <summary>
        /// Is called when smtp client has finished reading AUTH LOGIN user send server response line.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="count"></param>
        /// <param name="exception"></param>
        /// <param name="tag"></param> 
        private void OnAuthLoginUserReadServerResponseFinished(SocketCallBackResult result,
                                                               long count,
                                                               Exception exception,
                                                               object tag)
        {
            Auth_state_data stateData = (Auth_state_data) tag;

            try
            {
                if (result == SocketCallBackResult.Ok)
                {
                    string responseLine = Encoding.ASCII.GetString(((MemoryStream) stateData.Tag).ToArray());

                    // Response line must start with 334 or otherwise it's error response
                    if (!responseLine.StartsWith("334"))
                    {
                        throw new Exception(responseLine);
                    }
                    else
                    {
                        // Start sending password to server
                        m_pSocket.BeginWriteLine(
                            Convert.ToBase64String(Encoding.ASCII.GetBytes(stateData.Password)),
                            stateData,
                            OnAuthLoginPasswordSendFinished);
                    }
                }
                else
                {
                    HandleSocketError(result, exception);
                }
            }
            catch (Exception x)
            {
                // Pass exception to callback method
                stateData.Callback(SocketCallBackResult.Exception, x);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:45,代码来源:SmtpClientEx.cs


注:本文中的SocketCallBackResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。