static public void Theout() { FFLog.Trace(string.Format("theout! {0}", System.Threading.Thread.CurrentThread.ManagedThreadId.ToString())); FFLog.Debug("AAAAAAAAAAAAAAA1"); FFLog.Trace("AAAAAAAAAAAAAAA2"); FFLog.Info("AAAAAAAAAAAAAAA3"); FFLog.Warning("AAAAAAAAAAAAAAA4"); FFLog.Error("AAAAAAAAAAAAAAA5"); }
public void HandleRecv(IAsyncResult ar) { if (m_nStatus == 0) { FFLog.Trace("scoket: HandleRecv has closed"); return; } var length = 0; try { Socket socket = (Socket)ar.AsyncState; if (socket == null || m_oSocket == null) { return; } length = socket.EndReceive(ar); } catch (Exception ex) { FFLog.Warning("scoket: recv Error1 " + ex.Message); HandleClose(); return; } //FFLog.Trace(string.Format("scoket: recv 1111 {0}", length)); if (length == 0) { FFLog.Warning("HandleRecv: recv end ok file "); HandleClose(); return; } FFNet.GetTaskQueue().Post(() => { try { byte[] message = new byte[length]; Array.Copy(m_oBuffer, 0, message, 0, length); PostMsg(message); //接收下一个消息 if (m_oSocket != null) { m_oSocket.BeginReceive(m_oBuffer, 0, m_oBuffer.Length, SocketFlags.None, new AsyncCallback(HandleRecv), m_oSocket); } } catch (Exception ex) { FFLog.Error("scoket: recv Error2 " + ex.Message); HandleClose(); } }); }
private void handleSendEnd(IAsyncResult ar) { var socket = ar.AsyncState as Socket; try { if (socket == null || m_oSocket == null || !socket.Connected) { return; } socket.EndSend(ar); } catch (Exception ex) { FFLog.Warning("scoket: send Error1 " + ex.Message); HandleClose(); return; } FFNet.GetTaskQueue().Post(() => { try { if (m_oBuffSending.Count > 0) { m_oBuffSending.RemoveAt(0); } if (m_oBuffSending.Count > 0 && m_oSocket != null) { byte[] data = m_oBuffSending[0]; m_oSocket.BeginSend(data, 0, data.Length, 0, new AsyncCallback(handleSendEnd), m_oSocket); } } catch (Exception ex) { FFLog.Trace("scoket: send Error " + ex.Message); HandleClose(); } }); }