Esempio n. 1
0
            /// <summary>
            /// 接收
            /// </summary>
            /// <param name="ar"></param>
            public static void Receive(IAsyncResult ar)
            {
                UserSock self = (UserSock)ar.AsyncState;

                if (self.m_State == SockState.Idle)
                {
                    return;
                }
                int size;

                try
                {
                    size = self.m_Socket.EndReceive(ar);
                }
                catch (SocketException e)
                {
                    if (self.m_Socket.Connected)
                    {
                        self.SetSockError(e.ErrorCode, e.Message);
                    }
                    else
                    {
                        self.Close();
                    }
                    return;
                }
                catch (Exception)
                {
                    return;
                }
                self.StopReceive(size);
            }
Esempio n. 2
0
 public bool Disconnect()
 {
     return(m_scoket.Close());
 }