public void StartReceive() { if (IsConnected() == false) { Disconnect(); flagReceiving.ForceFalse(); return; } try { bool pending = true; pending = m_Socket.ReceiveAsync(m_RecvSAEA); flagReceiving.ForceTrue(); // pending값이 false라면 동기적으로 처리가 완료되서 여기서 바로 처리해줘야함 if (pending == false) { ProcessReceive(m_RecvSAEA); } } catch (Exception e) { OnError("StartReceive", e); flagReceiving.ForceFalse(); Disconnect(CloseReason.SocketError); return; } }
public void StartSend() { if (IsConnected() == false) { return; } if (m_SendQueue.Count <= 0) { return; } if (flagSending.SetTrue() == false) { return; } try { bool pending = true; m_SendingList.Clear(); ArraySegment <byte> arraySeg; while (m_SendQueue.TryDequeue(out arraySeg)) { m_SendingList.Add(arraySeg); } m_SendSAEA.BufferList = m_SendingList; pending = m_Socket.SendAsync(m_SendSAEA); // pending값이 false라면 동기적으로 처리가 완료되서 여기서 바로 처리해줘야함 if (pending == false) { ProcessSend(m_SendSAEA); } } catch (Exception e) { OnError("StartReceive", e); flagSending.ForceFalse(); Disconnect(CloseReason.SocketError); return; } }