示例#1
0
        static void Main(string[] args)
        {
            try
            {
                string textProtocolIP   = MemConfiguration.TextProtocolIP;
                int    textPort         = MemConfiguration.TextProtocolPort;
                string binaryProtocolIP = MemConfiguration.BinaryProtocolIP;
                int    binaryPort       = MemConfiguration.BinaryProtocolPort;

                if (textPort == binaryPort)
                {
                    throw new ArgumentException("Ports cannot be same for text and binary protocol.");
                }

                TcpNetworkGateway tcpTextGateWay = new TcpNetworkGateway(textProtocolIP, textPort, Alachisoft.NCache.Integrations.Memcached.ProxyServer.NetworkGateway.ProtocolType.Text);
                tcpTextGateWay.StartListenForClients();
                LogManager.Logger.Info("Proxy server for text protocol started at IP: " + textProtocolIP + " port: " + textPort);

                TcpNetworkGateway tcpBinaryGateWay = new TcpNetworkGateway(binaryProtocolIP, binaryPort, Alachisoft.NCache.Integrations.Memcached.ProxyServer.NetworkGateway.ProtocolType.Binary);
                tcpBinaryGateWay.StartListenForClients();
                LogManager.Logger.Info("Proxy server for binary protocol started at IP: " + binaryProtocolIP + " port: " + binaryPort);
            }
            catch (Exception e)
            {
                LogManager.Logger.Fatal("Service", "\t Failed to start proxy server. " + e.Message);
            }

            Console.WriteLine("Press Esc to exit.");
            ConsoleKey inputKey;

            do
            {
                inputKey = Console.ReadKey(false).Key;
            } while (inputKey != ConsoleKey.Escape);
            CacheFactory.DisposeCacheProvider();
        }
示例#2
0
 void IDisposable.Dispose()
 {
     CacheFactory.DisposeCacheProvider();
 }
 protected override void OnStop()
 {
     _tcpTextGateWay.StopListenForClients();
     _tcpBinaryGateWay.StopListenForClients();
     CacheFactory.DisposeCacheProvider();
 }