void Send_End(IAsyncResult ar) { Write_SO stateObj = (Write_SO)ar.AsyncState; try { stateObj.UpdateContext(); int sent = _socket.EndSend(ar); stateObj.Sent += sent; if (stateObj.Sent < stateObj.Size) { _socket.BeginSend( stateObj.Buffer, stateObj.Offset + stateObj.Sent, stateObj.Size - stateObj.Sent, new AsyncCallback(Send_End), stateObj); } else { stateObj.SetCompleted(); } } catch (Exception e) { if (_disposed) { stateObj.Exception = GetDisposedException(); } else { stateObj.Exception = e; } stateObj.SetCompleted(); } /* * catch * { * if(_disposed) * stateObj.Exception = GetDisposedException(); * else * stateObj.Exception = new SocketException(SockErrors.WSAECONNRESET); * stateObj.SetCompleted(); * } */ }
private void Send_End(IAsyncResult ar) { Write_SO asyncState = (Write_SO)ar.AsyncState; try { asyncState.UpdateContext(); int num = this._socket.EndSend(ar); asyncState.Sent += num; if (asyncState.Sent < asyncState.Size) { this._socket.BeginSend(asyncState.Buffer, asyncState.Offset + asyncState.Sent, asyncState.Size - asyncState.Sent, new AsyncCallback(this.Send_End), asyncState); } else { asyncState.SetCompleted(); } } catch (Exception exception) { if (this._disposed) { asyncState.Exception = this.GetDisposedException(); } else { asyncState.Exception = exception; } asyncState.SetCompleted(); } catch { if (this._disposed) { asyncState.Exception = this.GetDisposedException(); } else { asyncState.Exception = new SocketException(0x2746); } asyncState.SetCompleted(); } }