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, this.GetCurrentReplicationPort()); this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs); netPath.ApplyNetworkPolicy(dagConfig); tcpClientChannel = this.TryConnect(netPath, out ex); if (tcpClientChannel == null) { throw ex; } } return(tcpClientChannel); }
public static DagNetRoute[] ProposeRoutes(string targetServer, out DagNetConfig dagNetConfig) { DagNetChooser netChooser = DagNetEnvironment.NetChooser; return(netChooser.BuildRoutes(targetServer, out dagNetConfig)); }