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.TraceException <TimeoutException>(new TimeoutException(Microsoft.ServiceBus.SR.GetString(tcpConnectionTimedOut, objArray)), this.ExceptionEventType, this.Activity); } if (Microsoft.ServiceBus.Channels.SocketConnection.UpdateTimeout(this.sendTimeout, timeout)) { lock (this.ThisLock) { this.ThrowIfClosed(); this.socket.SendTimeout = Microsoft.ServiceBus.Common.TimeoutHelper.ToMilliseconds(timeout); } this.sendTimeout = timeout; return; } } }
private void CloseSync() { byte[] numArray = new byte[1]; this.readFinTimeout = this.closeTimeoutHelper.RemainingTime(); try { if (this.ReadCore(numArray, 0, 1, this.readFinTimeout, true) > 0) { ExceptionTrace exception = Fx.Exception; string socketCloseReadReceivedData = Resources.SocketCloseReadReceivedData; object[] remoteIPEndPointString = new object[] { this.RemoteIPEndPointString }; throw exception.TraceException <CommunicationException>(new CommunicationException(Microsoft.ServiceBus.SR.GetString(socketCloseReadReceivedData, remoteIPEndPointString)), this.ExceptionEventType, this.Activity); } } catch (TimeoutException timeoutException1) { TimeoutException timeoutException = timeoutException1; ExceptionTrace exceptionTrace = Fx.Exception; string socketCloseReadTimeout = Resources.SocketCloseReadTimeout; object[] objArray = new object[] { this.RemoteIPEndPointString, this.readFinTimeout }; throw exceptionTrace.TraceException <TimeoutException>(new TimeoutException(Microsoft.ServiceBus.SR.GetString(socketCloseReadTimeout, objArray), timeoutException), this.ExceptionEventType, this.Activity); } this.ContinueClose(this.closeTimeoutHelper.RemainingTime()); }