} // Next private TcpClientSocketHandler SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream) { // If the stream is seekable, we can retry once on a failure to write. long initialPosition = 0; bool bCanSeek = requestStream.CanSeek; if (bCanSeek) { initialPosition = requestStream.Position; } TcpClientSocketHandler clientSocket = null; try { clientSocket = (TcpClientSocketHandler)ClientSocketCache.GetSocket(_machineAndPort); clientSocket.SendRequest(msg, requestHeaders, requestStream); } catch (SocketException) { // retry sending if possible if (bCanSeek) { // reset position... requestStream.Position = initialPosition; // ...and try again. clientSocket = (TcpClientSocketHandler) ClientSocketCache.GetSocket(_machineAndPort); clientSocket.SendRequest(msg, requestHeaders, requestStream); } } requestStream.Close(); return(clientSocket); } // SendRequestWithRetry
} // Next private TcpClientSocketHandler SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream) { // If the stream is seekable, we can retry once on a failure to write. long initialPosition = 0; bool sendException = true; bool bCanSeek = requestStream.CanSeek; if (bCanSeek) { initialPosition = requestStream.Position; } TcpClientSocketHandler clientSocket = null; // Add the sid string only if the channel is secure. String machinePortAndSid = _machineAndPort + (_channel.IsSecured ? "/" + GetSid() : null); // The authentication config entries are only valid if secure is true if (authSet && !_channel.IsSecured) { throw new RemotingException(CoreChannel.GetResourceString( "Remoting_Tcp_AuthenticationConfigClient")); } // If explicitUserName is set but connectionGroupName isnt we will need to authenticate on each call bool openNewAlways = (_channel.IsSecured) && (_securityUserName != null) && (_connectionGroupName == null); try { clientSocket = (TcpClientSocketHandler)ClientSocketCache.GetSocket(machinePortAndSid, openNewAlways); clientSocket.SendRequest(msg, requestHeaders, requestStream); } catch (SocketException) { // Retry sending if socketexception occured, stream is seekable, retrycount times for (int count = 0; (count < _retryCount) && (bCanSeek && sendException); count++) { // retry sending if possible try { // reset position... requestStream.Position = initialPosition; // ...and try again. clientSocket = (TcpClientSocketHandler) ClientSocketCache.GetSocket(machinePortAndSid, openNewAlways); clientSocket.SendRequest(msg, requestHeaders, requestStream); sendException = false; } catch (SocketException) { } } if (sendException) { throw; } } requestStream.Close(); return(clientSocket); } // SendRequestWithRetry