Пример #1
0
        public void Init(Binding binding)
        {
            this.fBinding = binding;
            this.fDataSocket = new Socket(binding.AddressFamily, binding.SocketType, binding.Protocol);

            if (!this.EnableNagle)
                this.fDataSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);
        }
Пример #2
0
		public Connection(Binding binding)
		{
			this.fSyncRoot = new Object();

			this.Init(binding);

			this.SetDefaultValues();
		}
Пример #3
0
 public ConnectionPool(Binding bindingV4, Binding bindingV6)
     : base()
 {
     this.fBindingV4 = bindingV4;
     this.fBindingV6 = bindingV6;
     this.fCleanupTimer = new Timer(new TimerCallback(Cleanup), null, 30000, 30000);
     this.fMaxQueuePerHost = 5;
     this.fTimeout = 260;
 }
Пример #4
0
		public ConnectionPool(Binding bindingV4, Binding bindingV6)
		{
			this.fCache = new Hashtable();
			this.fBindingV4 = bindingV4;
			this.fBindingV6 = bindingV6;
			this.fCleanupTimer = new Timer(CleanupCallback, null, 30000, 30000);
			this.fMaxQueuePerHost = 5;
			this.Timeout = 260;
		}
Пример #5
0
			public InnerConnection(Binding binding)
				: base(binding)
			{
			}
Пример #6
0
		public SslConnection(SslConnectionFactory factory, Binding binding)
			: base((Socket)null)
		{
			this.fFactory = factory;
			this.fInnerConnection = new InnerConnection(binding);
			this.fInnerConnection.BufferedAsync = false;
			this.fInnerConnection.AsyncDisconnect += InnerConnection_AsyncDisconnect;
			this.fInnerConnection.AsyncHaveIncompleteData += InnerConnection_AsyncHaveIncompleteData;
		}
Пример #7
0
 public Connection(Binding binding)
 {
     this.Init(binding);
     this.Initialize();
 }
Пример #8
0
        public virtual Connection GetNewConnection(EndPoint endPoint)
        {
            Binding lBinding;
            switch (endPoint.AddressFamily)
            {
                case AddressFamily.InterNetwork:
                    lBinding = fBindingV4;
                    break;

                case AddressFamily.InterNetworkV6:
                    lBinding = fBindingV6;
                    break;

                default:
                    lBinding = new Binding(endPoint.AddressFamily);
                    break;
            }

            Connection lConnection;
            if (this.fConnectionFactory != null)
                lConnection = this.fConnectionFactory.CreateClientConnection(lBinding);
            else if (fConnectionClass != null)
                lConnection = (Connection)Activator.CreateInstance(this.fConnectionClass);
            else
                lConnection = new Connection(lBinding);

            lConnection.Connect(endPoint);
            lConnection.LastUsed = DateTime.Now;
            lConnection.Pool = this;

            return lConnection;
        }
		public virtual Connection CreateClientConnection(Binding binding)
		{
			if (!this.Enabled)
			{
				return new Connection(binding);
			}

			if (this.IsCertificateLoadPending)
			{
				this.LoadCertificate();
			}

			return new SslConnection(this, binding);
		}
Пример #10
0
        public static Connection Connect(String hostname, Int32 port, Binding binding)
        {
            IPAddress lHostAddress = Dns.DnsLookup.ResolveFirst(hostname);

            return Client.Connect(lHostAddress, port, binding);
        }
Пример #11
0
        public static Connection Connect(IPAddress host, Int32 port, Binding binding)
        {
            Connection lConnection = new Connection(binding);
            lConnection.Connect(host, port);

            return lConnection;
        }
Пример #12
0
        protected virtual Connection NewConnection(Binding binding)
        {
            if (this.fConnectionFactory != null)
                return this.fConnectionFactory.CreateClientConnection(binding);

            if (this.fConnectionClass != null)
                return (Connection)Activator.CreateInstance(this.fConnectionClass);

#if FULLFRAMEWORK
            if (this.SslOptions.Enabled)
            {
                Connection lSslConnection = this.SslOptions.CreateClientConnection(binding);
                lSslConnection.EnableNagle = this.EnableNagle;

                return lSslConnection;
            }
#endif
            Connection lConnection = new Connection(binding);
            lConnection.EnableNagle = this.EnableNagle;

            return lConnection;
        }
Пример #13
0
        protected virtual Connection GetConnection(IPAddress host, Int32 port)
        {
            if (this.fConnectionPool != null)
                return this.fConnectionPool.GetConnection(new IPEndPoint(host, port));

            Binding lBinding;
            switch (host.AddressFamily)
            {
                case AddressFamily.InterNetwork:
                    lBinding = this.fBindingV4;
                    break;

                case AddressFamily.InterNetworkV6:
                    lBinding = this.fBindingV6;
                    break;

                default:
                    lBinding = new Binding(host.AddressFamily);
                    break;
            }

            Connection lConnection = this.NewConnection(lBinding);
            lConnection.Connect(host, port);

            return lConnection;
        }
Пример #14
0
 public SslConnection(SslConnectionFactory factory, Binding binding)
     : base((Socket)null)
 {
     fFactory = factory;
     fInnerConnection = new InnerConnection(binding);
     fInnerConnection.BufferedAsync = false;
     fInnerConnection.AsyncDisconnect += new EventHandler(InnerConnection_AsyncDisconnect);
     fInnerConnection.AsyncHaveIncompleteData += new EventHandler(InnerConnection_AsyncHaveIncompleteData);
 }
Пример #15
0
        public virtual Connection CreateClientConnection(Binding binding)
        {
            if (!this.Enabled)
                return new Connection(binding);

            if (this.HasCertificate)
                this.LoadCertificate();

            return new SslConnection(this, binding);
        }
Пример #16
0
        public static Connection Connect(String hostname, Int32 port, Binding binding)
        {
            IPAddress lHostAddress = Dns.DnsLookup.ResolveFirst(hostname);

            return(Client.Connect(lHostAddress, port, binding));
        }