Exemplo n.º 1
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client message.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_ClientMessage owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pOwner      = owner;
                m_pPop3Client = owner.m_Pop3Client;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1939 5. RETR
                         Arguments:
                             a message-number (required) which may NOT refer to a
                             message marked as deleted

                         Restrictions:
                             may only be given in the TRANSACTION state

                         Discussion:
                             If the POP3 server issues a positive response, then the
                             response given is multi-line.  After the initial +OK, the
                             POP3 server sends the message corresponding to the given
                             message-number, being careful to byte-stuff the termination
                             character (as with all multi-line responses).

                         Possible Responses:
                             +OK message follows
                             -ERR no such message

                         Examples:
                             C: RETR 1
                             S: +OK 120 octets
                             S: <the POP3 server sends the entire message here>
                             S: .
			        */

                    byte[] buffer = Encoding.UTF8.GetBytes("RETR " + owner.SequenceNumber.ToString() + "\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"RETR " + owner.SequenceNumber.ToString());

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.RetrCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client message.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_ClientMessage owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pOwner      = owner;
                m_pPop3Client = owner.m_Pop3Client;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1939 7. TOP
                         Arguments:
                             a message-number (required) which may NOT refer to to a
                             message marked as deleted, and a non-negative number
                             of lines (required)

                         Restrictions:
                             may only be given in the TRANSACTION state

                         Discussion:
                             If the POP3 server issues a positive response, then the
                             response given is multi-line.  After the initial +OK, the
                             POP3 server sends the headers of the message, the blank
                             line separating the headers from the body, and then the
                             number of lines of the indicated message's body, being
                             careful to byte-stuff the termination character (as with
                             all multi-line responses).

                             Note that if the number of lines requested by the POP3
                             client is greater than than the number of lines in the
                             body, then the POP3 server sends the entire message.

                         Possible Responses:
                             +OK top of message follows
                             -ERR no such message

                         Examples:
                             C: TOP 1 10
                             S: +OK
                             S: <the POP3 server sends the headers of the
                                message, a blank line, and the first 10 lines
                                of the body of the message>
                             S: .
                                ...
                             C: TOP 100 3
                             S: -ERR no such message
			        */

                    byte[] buffer = Encoding.UTF8.GetBytes("TOP " + owner.SequenceNumber.ToString()+ " " + m_LineCount.ToString() + "\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"TOP " + owner.SequenceNumber.ToString()+ " " + m_LineCount.ToString());

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.TopCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 3
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client message.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_ClientMessage owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pOwner      = owner;
                m_pPop3Client = owner.m_Pop3Client;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1939 5. DELE
                         Arguments:
                             a message-number (required) which may NOT refer to a
                             message marked as deleted

                         Restrictions:
                             may only be given in the TRANSACTION state

                         Discussion:
                             The POP3 server marks the message as deleted.  Any future
                             reference to the message-number associated with the message
                             in a POP3 command generates an error.  The POP3 server does
                             not actually delete the message until the POP3 session
                             enters the UPDATE state.

                         Possible Responses:
                             +OK message deleted
                             -ERR no such message

                         Examples:
                             C: DELE 1
                             S: +OK message 1 deleted
                                ...
                             C: DELE 2
                             S: -ERR message 2 already deleted
			        */

                    byte[] buffer = Encoding.UTF8.GetBytes("DELE " + owner.SequenceNumber.ToString() + "\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"DELE " + owner.SequenceNumber.ToString());

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.DeleCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 4
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 2595 4. POP3 STARTTLS extension.
                        Arguments: none

                        Restrictions:
                            Only permitted in AUTHORIZATION state.
                     
                        Possible Responses:
                             +OK -ERR

                         Examples:
                             C: STLS
                             S: +OK Begin TLS negotiation
                             <TLS negotiation, further commands are under TLS layer>
                               ...
                             C: STLS
                             S: -ERR Command not permitted when TLS active
                    */

                    byte[] buffer = Encoding.UTF8.GetBytes("STLS\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"STLS");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.StlsCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 5
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 5034 4. The AUTH Command.

                        AUTH mechanism [initial-response]

                        Arguments:

                        mechanism: A string identifying a SASL authentication mechanism.

                        initial-response: An optional initial client response, as
                                          defined in Section 3 of [RFC4422].  If present, this response
                                          MUST be encoded as Base64 (specified in Section 4 of
                                          [RFC4648]), or consist only of the single character "=", which
                                          represents an empty initial response.
                    */

                    if(m_pSASL.SupportsInitialResponse){
                        byte[] buffer = Encoding.UTF8.GetBytes("AUTH " + m_pSASL.Name + " " + Convert.ToBase64String(m_pSASL.Continue(null)) + "\r\n");

                        // Log
                        m_pPop3Client.LogAddWrite(buffer.Length,Encoding.UTF8.GetString(buffer).TrimEnd());

                        // Start command sending.
                        m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.AuthCommandSendingCompleted,null);
                    }
                    else{
                        byte[] buffer = Encoding.UTF8.GetBytes("AUTH " + m_pSASL.Name + "\r\n");

                        // Log
                        m_pPop3Client.LogAddWrite(buffer.Length,"AUTH " + m_pSASL.Name);

                        // Start command sending.
                        m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.AuthCommandSendingCompleted,null);
                    }
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 6
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1935.5. LIST
                         Arguments:
                             a message-number (optional), which, if present, may NOT
                             refer to a message marked as deleted 

                         Restrictions:
                             may only be given in the TRANSACTION state

                         Discussion:
                             If an argument was given and the POP3 server issues a
                             positive response with a line containing information for
                             that message.  This line is called a "scan listing" for
                             that message.

                             If no argument was given and the POP3 server issues a
                             positive response, then the response given is multi-line.
                             After the initial +OK, for each message in the maildrop,
                             the POP3 server responds with a line containing
                             information for that message.  This line is also called a
                             "scan listing" for that message.  If there are no
                             messages in the maildrop, then the POP3 server responds
                             with no scan listings--it issues a positive response
                             followed by a line containing a termination octet and a
                             CRLF pair.

                             In order to simplify parsing, all POP3 servers are
                             required to use a certain format for scan listings.  A
                             scan listing consists of the message-number of the
                             message, followed by a single space and the exact size of
                             the message in octets.  Methods for calculating the exact
                             size of the message are described in the "Message Format"
                             section below.  This memo makes no requirement on what
                             follows the message size in the scan listing.  Minimal
                             implementations should just end that line of the response
                             with a CRLF pair.  More advanced implementations may
                             include other information, as parsed from the message.

                                NOTE: This memo STRONGLY discourages implementations
                                from supplying additional information in the scan
                                listing.  Other, optional, facilities are discussed
                                later on which permit the client to parse the messages
                                in the maildrop.

                             Note that messages marked as deleted are not listed.

                         Possible Responses:
                             +OK scan listing follows
                             -ERR no such message

                         Examples:
                             C: LIST
                             S: +OK 2 messages (320 octets)
                             S: 1 120
                             S: 2 200
                             S: .
                               ...
                             C: LIST 2
                             S: +OK 2 200
                               ...
                             C: LIST 3
                             S: -ERR no such message, only 2 messages in maildrop
                    */

                    byte[] buffer = Encoding.UTF8.GetBytes("LIST\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"LIST");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.ListCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 7
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1935.7. UIDL
                      Arguments:
                          a message-number (optional), which, if present, may NOT
                          refer to a message marked as deleted

                      Restrictions:
                          may only be given in the TRANSACTION state.

                      Discussion:
                          If an argument was given and the POP3 server issues a positive
                          response with a line containing information for that message.
                          This line is called a "unique-id listing" for that message.

                          If no argument was given and the POP3 server issues a positive
                          response, then the response given is multi-line.  After the
                          initial +OK, for each message in the maildrop, the POP3 server
                          responds with a line containing information for that message.
                          This line is called a "unique-id listing" for that message.

                          In order to simplify parsing, all POP3 servers are required to
                          use a certain format for unique-id listings.  A unique-id
                          listing consists of the message-number of the message,
                          followed by a single space and the unique-id of the message.
                          No information follows the unique-id in the unique-id listing.

                          The unique-id of a message is an arbitrary server-determined
                          string, consisting of one to 70 characters in the range 0x21
                          to 0x7E, which uniquely identifies a message within a
                          maildrop and which persists across sessions.  This
                          persistence is required even if a session ends without
                          entering the UPDATE state.  The server should never reuse an
                          unique-id in a given maildrop, for as long as the entity
                          using the unique-id exists.

                          Note that messages marked as deleted are not listed.

                          While it is generally preferable for server implementations
                          to store arbitrarily assigned unique-ids in the maildrop,
                          this specification is intended to permit unique-ids to be
                          calculated as a hash of the message.  Clients should be able
                          to handle a situation where two identical copies of a
                          message in a maildrop have the same unique-id.

                      Possible Responses:
                          +OK unique-id listing follows
                          -ERR no such message

                      Examples:
                          C: UIDL
                          S: +OK
                          S: 1 whqtswO00WBw418f9t5JxYwZ
                          S: 2 QhdPYR:00WBw1Ph7x7
                          S: .
                             ...
                          C: UIDL 2
                          S: +OK 2 QhdPYR:00WBw1Ph7x7
                             ...
                          C: UIDL 3
                          S: -ERR no such message, only 2 messages in maildrop
                    */

                    byte[] buffer = Encoding.UTF8.GetBytes("UIDL\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"UIDL");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.UidlCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 8
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    // Start executing LIST command.
                    POP3_Client.ListAsyncOP listOP = new ListAsyncOP();
                    listOP.CompletedAsync += delegate(object sender,EventArgs<ListAsyncOP> e){
                        ListCompleted(listOP);
                    };
                    if(!m_pPop3Client.ListAsync(listOP)){
                        ListCompleted(listOP);
                    }
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 9
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1939 5. RSET.
                        Arguments: none

                        Restrictions:
                            may only be given in the TRANSACTION state

                        Discussion:
                            If any messages have been marked as deleted by the POP3
                            server, they are unmarked.  The POP3 server then replies
                            with a positive response.

                        Possible Responses:
                            +OK

                        Examples:
                            C: RSET
                            S: +OK maildrop has 2 messages (320 octets)
			        */

                    byte[] buffer = Encoding.UTF8.GetBytes("RSET\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"RSET");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.RsetCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 10
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 2449 CAPA
                        Arguments:
                            none

                        Restrictions:
                            none

                        Discussion:
                            An -ERR response indicates the capability command is not
                            implemented and the client will have to probe for
                            capabilities as before.

                            An +OK response is followed by a list of capabilities, one
                            per line.  Each capability name MAY be followed by a single
                            space and a space-separated list of parameters.  Each
                            capability line is limited to 512 octets (including the
                            CRLF).  The capability list is terminated by a line
                            containing a termination octet (".") and a CRLF pair.

                        Possible Responses:
                            +OK -ERR

                        Examples:
                            C: CAPA
                            S: +OK Capability list follows
                            S: TOP
                            S: USER
                            S: SASL CRAM-MD5 KERBEROS_V4
                            S: RESP-CODES
                            S: LOGIN-DELAY 900
                            S: PIPELINING
                            S: EXPIRE 60
                            S: UIDL
                            S: IMPLEMENTATION Shlemazle-Plotz-v302
                            S: .
                    */

                    byte[] buffer = Encoding.UTF8.GetBytes("CAPA\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"CAPA");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.CapaCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 11
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    /* RFC 1939 5 NOOP.
                        Arguments: none

                        Restrictions:
                            may only be given in the TRANSACTION state

                        Discussion:
                            The POP3 server does nothing, it merely replies with a
                            positive response.

                        Possible Responses:
                            +OK

                        Examples:
                            C: NOOP
                            S: +OK
                    */

                    byte[] buffer = Encoding.UTF8.GetBytes("NOOP\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"NOOP");

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.NoopCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }
Exemplo n.º 12
0
            /// <summary>
            /// Starts operation processing.
            /// </summary>
            /// <param name="owner">Owner POP3 client.</param>
            /// <returns>Returns true if asynchronous operation in progress or false if operation completed synchronously.</returns>
            /// <exception cref="ArgumentNullException">Is raised when <b>owner</b> is null reference.</exception>
            internal bool Start(POP3_Client owner)
            {
                if(owner == null){
                    throw new ArgumentNullException("owner");
                }

                m_pPop3Client = owner;

                SetState(AsyncOP_State.Active);

                try{
                    byte[] buffer = Encoding.UTF8.GetBytes("USER " + m_User + "\r\n");

                    // Log
                    m_pPop3Client.LogAddWrite(buffer.Length,"USER " + m_User);

                    // Start command sending.
                    m_pPop3Client.TcpStream.BeginWrite(buffer,0,buffer.Length,this.UserCommandSendingCompleted,null);
                }
                catch(Exception x){
                    m_pException = x;
                    m_pPop3Client.LogAddException("Exception: " + x.Message,x);
                    SetState(AsyncOP_State.Completed);
                }

                // Set flag rise CompletedAsync event flag. The event is raised when async op completes.
                // If already completed sync, that flag has no effect.
                lock(m_pLock){
                    m_RiseCompleted = true;

                    return m_State == AsyncOP_State.Active;
                }
            }