public TcpClientChannel TryConnect(NetworkPath netPath, int timeoutInMsec, out NetworkTransportException failureEx) { TcpClientChannel result = null; TcpClientChannel.TryOpenChannel(netPath, timeoutInMsec, out result, out failureEx); return(result); }
internal static TcpClientChannel OpenConnection(ref NetworkPath actualPath, int timeoutInMsec, bool ignoreNodeDown) { NetworkPath networkPath = actualPath; NetworkTransportException ex = null; ITcpConnector tcpConnector = Dependencies.TcpConnector; TcpClientChannel tcpClientChannel = tcpConnector.TryConnect(networkPath, timeoutInMsec, out ex); if (tcpClientChannel != null) { return tcpClientChannel; } if (!networkPath.NetworkChoiceIsMandatory) { NetworkManager.TraceError("Attempting alternate routes", new object[0]); List<NetworkPath> list = null; ExchangeNetworkMap map = NetworkManager.GetMap(); if (map != null) { list = map.EnumeratePaths(networkPath.TargetNodeName, ignoreNodeDown); if (list != null) { NetworkPath networkPath2 = null; foreach (NetworkPath networkPath3 in list) { if (string.Equals(networkPath3.NetworkName, networkPath.NetworkName, DatabaseAvailabilityGroupNetwork.NameComparison)) { networkPath2 = networkPath3; break; } } if (networkPath2 != null) { list.Remove(networkPath2); } DagNetConfig dagConfig = DagNetEnvironment.FetchNetConfig(); foreach (NetworkPath networkPath4 in list) { networkPath4.Purpose = networkPath.Purpose; networkPath4.ApplyNetworkPolicy(dagConfig); tcpClientChannel = tcpConnector.TryConnect(networkPath, timeoutInMsec, out ex); if (tcpClientChannel != null) { actualPath = networkPath4; return tcpClientChannel; } } } } } throw ex; }
public TcpClientChannel OpenChannel(string targetServerName, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs, out NetworkPath netPath) { DagNetConfig dagConfig; DagNetRoute[] array = DagNetChooser.ProposeRoutes(targetServerName, out dagConfig); TcpClientChannel tcpClientChannel = null; netPath = null; NetworkTransportException ex = null; if (array != null) { foreach (DagNetRoute dagNetRoute in array) { netPath = new NetworkPath(targetServerName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr); netPath.CrossSubnet = dagNetRoute.IsCrossSubnet; this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs); netPath.ApplyNetworkPolicy(dagConfig); tcpClientChannel = this.TryConnect(netPath, out ex); if (tcpClientChannel != null) { break; } } } if (tcpClientChannel == null) { netPath = this.BuildDnsNetworkPath(targetServerName, (int)NetworkManager.GetReplicationPort()); this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs); netPath.ApplyNetworkPolicy(dagConfig); tcpClientChannel = this.TryConnect(netPath, out ex); if (tcpClientChannel == null) { throw ex; } } return(tcpClientChannel); }