Пример #1
0
 /// <summary>
 /// 从socket接收数据
 /// </summary>
 /// <param name="s"></param>
 /// <param name="readEventArgs"></param>
 private bool _ReceiveAsync(SocketAsyncEventArgs readEventArgs)
 {
     try
     {
         TMSKSocket s = (readEventArgs.UserToken as AsyncUserToken).CurrentSocket;
         return(s.ReceiveAsync(readEventArgs));
     }
     catch (Exception)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("在SocketListener::_ReceiveAsync 中发生了异常错误"));
         this.CloseClientSocket(readEventArgs);
         return(true);
     }
 }
Пример #2
0
 /// <summary>
 /// 从socket接收数据
 /// </summary>
 /// <param name="s"></param>
 /// <param name="readEventArgs"></param>
 private bool _ReceiveAsync(SocketAsyncEventArgs readEventArgs)
 {
     try
     {
         TMSKSocket s = (readEventArgs.UserToken as AsyncUserToken).CurrentSocket;
         return(s.ReceiveAsync(readEventArgs));
     }
     catch (Exception ex)
     {
         // SysConOut.WriteLine(string.Format("在SocketListener::_ReceiveAsync 中发生了异常错误"));
         LogManager.WriteLog(LogTypes.Error, string.Format("在SocketListener::_ReceiveAsync 中发生了异常错误"));
         string str = ex.Message.ToString();
         this.CloseClientSocket(readEventArgs, "_ReceiveAsync = " + str.Replace('\n', ' '));
         return(true);
     }
 }
Пример #3
0
        private bool _ReceiveAsync(SocketAsyncEventArgs readEventArgs)
        {
            bool result;

            try
            {
                TMSKSocket s = (readEventArgs.UserToken as AsyncUserToken).CurrentSocket;
                result = s.ReceiveAsync(readEventArgs);
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("在SocketListener::_ReceiveAsync 中发生了异常错误", new object[0]), null, true);
                string str = ex.Message.ToString();
                this.CloseClientSocket(readEventArgs, str.Replace('\n', ' '));
                result = true;
            }
            return(result);
        }