Example #1
0
        public void Open(int port)
        {
            if (port < 0 || port > 65536)
                throw new ArgumentOutOfRangeException("port", "port value is invalid");

            string urlService = "net.pipe://localhost/" + SERVICE_NAME + "_" + port.ToString();

            lock (mClientLocker)
            {
                if (mProxy != null)
                    return;

                var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                bind.MaxReceivedMessageSize = 2147483647;
                bind.MaxBufferSize = 2147483647;
                // Commented next statement since it is not required
                bind.MaxBufferPoolSize = 2147483647;
                bind.ReaderQuotas.MaxArrayLength = 2147483647;
                bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
                bind.ReaderQuotas.MaxDepth = 2147483647;
                bind.ReaderQuotas.MaxStringContentLength = 2147483647;
                bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;

                mProxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
                mProxy.Faulted += mProxy_Faulted;
            }
        }
Example #2
0
        public void Open(string host, int port)
        {
            Debug.WriteLine("[INFO] MtClient::Open");

            if (string.IsNullOrEmpty(host) == true)
                throw new ArgumentNullException("host", "host is null or epmty");

            if (port < 0 || port > 65536)
                throw new ArgumentOutOfRangeException("port", "port value is invalid");

            string urlService = string.Format("net.tcp://{0}:{1}/{2}", host, port, SERVICE_NAME);

            lock (mClientLocker)
            {
                if (mProxy != null)
                    return;

                var bind = new NetTcpBinding(SecurityMode.None);
                bind.MaxReceivedMessageSize = 2147483647;
                bind.MaxBufferSize = 2147483647;
                // Commented next statement since it is not required
                bind.MaxBufferPoolSize = 2147483647;
                bind.ReaderQuotas.MaxArrayLength = 2147483647;
                bind.ReaderQuotas.MaxBytesPerRead = 2147483647;
                bind.ReaderQuotas.MaxDepth = 2147483647;
                bind.ReaderQuotas.MaxStringContentLength = 2147483647;
                bind.ReaderQuotas.MaxNameTableCharCount = 2147483647;

                mProxy = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
                mProxy.Faulted += mProxy_Faulted;
            }
        }