private void BeginReceive() { if (IsConnected) { Buffers.Buffer buffer = (Buffers.Buffer)ReceiveBufferPool.Pop(); buffer.UserToken = this; try { buffer.AsyncFrom(mReceiveEventArgs, mSocket); } catch (Exception e_) { buffer.Free(); DisConnect(); ProcessError(e_, "client begin network receive error!"); } } }
public void BeginReceive() { if (IsConnected && System.Threading.Interlocked.Exchange(ref mReceiveState, 1) == 0) { Buffers.Buffer buffer = (Buffers.Buffer)BufferPool.Pop(); buffer.UserToken = this; try { buffer.AsyncFrom(mReceiveEventArgs, mSocket);/// see ref=<see cref="SocketAsyncEventArgs.Completed"/> } catch (Exception e_) { InitReceiveState(); buffer.Free(); DisConnect(); ProcessError(e_, "client begin network receive error!"); } } }
private void BeginReceive() { if (IsConnected) { Buffers.Buffer buffer = (Buffers.Buffer)BufferPool.ReceiveDefault.Pop(); if (!buffer.BindIOCompleted) { buffer.BindIOEvent(IO_Completed); } buffer.UserToken = this; try { buffer.AsyncFrom(mSocket); } catch (Exception e_) { buffer.Free(); DisConnect(); ProcessError(e_, "client begin network receive error!"); } } }