Ejemplo n.º 1
0
 public SocketStream(Socket socket, ISimpleBufferPool bufPool, IPool <SocketStreamAsyncArgs> asyncPool, SocketStream.ISocketStreamPerfCounters perfCtrs)
 {
     this.m_StreamSocket  = socket;
     this.m_bufPool       = bufPool;
     this.m_asyncArgsPool = asyncPool;
     this.m_perfCounters  = perfCtrs;
 }
Ejemplo n.º 2
0
 private void ApplySocketStreamArgs(NetworkPath netPath, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs)
 {
     if (socketStreamBufferPool != null)
     {
         netPath.SocketStreamBufferPool   = socketStreamBufferPool;
         netPath.SocketStreamAsyncArgPool = socketStreamAsyncArgPool;
         netPath.SocketStreamPerfCounters = perfCtrs;
         netPath.UseSocketStream          = true;
     }
 }
Ejemplo n.º 3
0
        public static NetworkChannel OpenChannel(string targetServerName, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs, bool suppressTransparentCompression)
        {
            if (socketStreamAsyncArgPool != null ^ socketStreamBufferPool != null)
            {
                string message = "SocketStream use requires both pools or neither";
                throw new ArgumentException(message);
            }
            ITcpConnector    tcpConnector = Dependencies.TcpConnector;
            NetworkPath      netPath      = null;
            TcpClientChannel tcpChannel   = tcpConnector.OpenChannel(targetServerName, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs, out netPath);

            return(NetworkChannel.FinishConnect(tcpChannel, netPath, suppressTransparentCompression));
        }
Ejemplo n.º 4
0
        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);
        }