private void ReceiveCb(IAsyncResult ar) { ConnToClient CTC = (ConnToClient)ar.AsyncState; try { if (CTC.IsUse == false) { return; } int count = CTC.socket.EndReceive(ar); if (count <= 0) { CTC.Close(); return; } CTC.BufferCount += count; PrcessByte(CTC); CTC.socket.BeginReceive(CTC.ReadBuffer, CTC.BufferCount, CTC.RetCount(), SocketFlags.None, ReceiveCb, CTC); } catch (Exception e) { CTC.Close(); Console.WriteLine(e.Message); } }
public void Hearbeat() { long TimeNow = Sys.GetListTime(); for (int i = 0; i < SCTCS.Length; i++) { if (SCTCS[i] == null) { continue; } ConnToClient CTC = SCTCS[i]; if (!CTC.IsUse) { continue; } if (CTC.LastHearBeatTime < TimeNow - HearbeatTime) { lock (CTC) CTC.Close(); } } }