public void Write(byte[] buffer, int offset, int size, bool immediate, TimeSpan timeout) { try { this.SetWriteTimeOut(timeout, true); this.Stream.Write(buffer, offset, size); } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), null); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } }
public override void Shutdown(TimeSpan timeout) { MessagingClientEtwProvider.Provider.WebStreamConnectionShutdown(base.Activity, this.factoryEndpointUri.AbsoluteUri, this.sbUri.AbsoluteUri); lock (base.ThisLock) { if (!base.IsShutdown) { base.IsShutdown = true; } else { return; } } try { ((WebStream)base.Stream).Shutdown(); } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsWarning(base.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsWarning(BaseStreamConnection.ConvertIOException(oException), null); } }
private void SetWriteTimeOut(TimeSpan timeout, bool synchronous) { if (!synchronous) { this.SendTimeout = timeout; if (timeout == TimeSpan.MaxValue) { this.CancelSendTimer(); return; } this.SendTimer.Set(timeout); } else { this.CancelSendTimer(); if (timeout <= TimeSpan.Zero) { ExceptionTrace exception = Fx.Exception; string tcpConnectionTimedOut = Resources.TcpConnectionTimedOut; object[] objArray = new object[] { timeout }; throw exception.AsInformation(new TimeoutException(Microsoft.ServiceBus.SR.GetString(tcpConnectionTimedOut, objArray)), null); } if (BaseStreamConnection.UpdateTimeout(this.SendTimeout, timeout)) { lock (this.ThisLock) { this.ThrowIfClosed(); } this.SendTimeout = timeout; return; } } }
private static void OnReceiveTimeout(object state) { BaseStreamConnection baseStreamConnection = (BaseStreamConnection)state; string socketAbortedReceiveTimedOut = Resources.SocketAbortedReceiveTimedOut; object[] receiveTimeout = new object[] { baseStreamConnection.ReceiveTimeout }; baseStreamConnection.Abort(Microsoft.ServiceBus.SR.GetString(socketAbortedReceiveTimedOut, receiveTimeout)); }
private static void OnSendTimeout(object state) { BaseStreamConnection baseStreamConnection = (BaseStreamConnection)state; string socketAbortedSendTimedOut = Resources.SocketAbortedSendTimedOut; object[] sendTimeout = new object[] { baseStreamConnection.SendTimeout }; baseStreamConnection.Abort(TraceEventType.Warning, Microsoft.ServiceBus.SR.GetString(socketAbortedSendTimedOut, sendTimeout)); }
public virtual void Close(TimeSpan timeout) { lock (this.ThisLock) { if (this.CloseState == BaseStreamConnection.State.Closing || this.CloseState == BaseStreamConnection.State.Closed) { return; } else { this.CloseState = BaseStreamConnection.State.Closing; } } try { this.Stream.Close(); } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), this.Activity); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), this.Activity); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } lock (this.ThisLock) { this.CloseState = BaseStreamConnection.State.Closed; } }
public IAsyncResult BeginWrite(byte[] buffer, int offset, int size, bool immediate, TimeSpan timeout, AsyncCallback callback, object state) { IAsyncResult asyncResult; try { lock (this.ThisLock) { this.SetWriteTimeOut(timeout, false); this.asyncWritePending = true; } IAsyncResult asyncResult1 = this.Stream.BeginWrite(buffer, offset, size, callback, state); asyncResult = asyncResult1; } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), null); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } return(asyncResult); }
protected int Read(byte[] buffer, int offset, int size, TimeSpan timeout, bool closing) { int num = 0; Microsoft.ServiceBus.Common.TimeoutHelper timeoutHelper = new Microsoft.ServiceBus.Common.TimeoutHelper(timeout); try { this.SetReadTimeout(timeoutHelper.RemainingTime(), true, closing); num = this.Stream.Read(buffer, offset, size); } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), null); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } return(num); }
public void EndWrite(IAsyncResult result) { try { this.CancelSendTimer(); lock (this.ThisLock) { this.asyncWritePending = false; } this.Stream.EndWrite(result); } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), null); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } }
private void OnRead(IAsyncResult result) { this.CancelReceiveTimer(); if (result.CompletedSynchronously) { return; } try { this.asyncReadSize = this.Stream.EndRead(result); } catch (ObjectDisposedException objectDisposedException) { this.asyncReadException = this.ConvertObjectDisposedException(objectDisposedException); } catch (IOException oException) { this.asyncReadException = BaseStreamConnection.ConvertIOException(oException); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } this.asyncReadException = Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } this.FinishRead(); }
public AsyncReadResult BeginRead(int offset, int size, TimeSpan timeout, WaitCallback callback, object state) { AsyncReadResult asyncReadResult; Microsoft.ServiceBus.Channels.ConnectionUtilities.ValidateBufferBounds(this.AsyncReadBufferSize, offset, size); bool flag = true; lock (this.ThisLock) { this.ThrowIfClosed(); this.asyncReadState = state; this.asyncReadCallback = callback; this.asyncReadPending = true; this.SetReadTimeout(timeout, false, false); } try { try { IAsyncResult asyncResult = this.Stream.BeginRead(this.AsyncReadBuffer, offset, size, this.onRead, null); if (asyncResult.CompletedSynchronously) { this.asyncReadSize = this.Stream.EndRead(asyncResult); flag = false; asyncReadResult = AsyncReadResult.Completed; } else { flag = false; asyncReadResult = AsyncReadResult.Queued; } } catch (ObjectDisposedException objectDisposedException1) { ObjectDisposedException objectDisposedException = objectDisposedException1; throw Fx.Exception.AsInformation(this.ConvertObjectDisposedException(objectDisposedException), null); } catch (IOException oException1) { IOException oException = oException1; throw Fx.Exception.AsInformation(BaseStreamConnection.ConvertIOException(oException), null); } catch (CommunicationException communicationException) { throw; } catch (TimeoutException timeoutException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new CommunicationException(exception.Message, exception), null); } throw; } } finally { if (flag) { this.AbortRead(); } } return(asyncReadResult); }