当前位置: 首页>>代码示例>>C#>>正文


C# ServicePoint.SetTcpKeepAlive方法代码示例

本文整理汇总了C#中System.Net.ServicePoint.SetTcpKeepAlive方法的典型用法代码示例。如果您正苦于以下问题:C# ServicePoint.SetTcpKeepAlive方法的具体用法?C# ServicePoint.SetTcpKeepAlive怎么用?C# ServicePoint.SetTcpKeepAlive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.ServicePoint的用法示例。


在下文中一共展示了ServicePoint.SetTcpKeepAlive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Worker

        public Worker(ParsingType type, PageParser parser, EventHandler onPageDownloadingComplete = null)
        {
            _type = type;
            _parser = parser;

            _address = LocaleMgr.GetAddress(parser.Locale);
            ServicePointManager.DefaultConnectionLimit = SemaphoreCount * 10;
            {
                _service = ServicePointManager.FindServicePoint(_address);
                _service.SetTcpKeepAlive(true, KeepAliveTime, KeepAliveTime);
            }
            _address = new Uri(_address, parser.Address);

            _semaphore = new SemaphoreSlim(SemaphoreCount, SemaphoreCount);
            _badIds = new ConcurrentQueue<uint>();

            PageDownloadingComplete += onPageDownloadingComplete;
        }
开发者ID:armano2,项目名称:WoWHead-data-parser,代码行数:18,代码来源:Worker.cs

示例2: Worker

        public Worker(ParsingType type, PageParser parser, EventHandler onPageDownloadingComplete = null)
        {
            m_type = type;
            m_parser = parser;

            m_address = new Uri(string.Format("http://{0}.wowhead.com/", parser.Locale.GetLocalePrefix()));
            ServicePointManager.DefaultConnectionLimit = SemaphoreCount * 10;
            {
                m_service = ServicePointManager.FindServicePoint(m_address);
                m_service.SetTcpKeepAlive(true, KeepAliveTime, KeepAliveTime);
            }

            m_semaphore = new SemaphoreSlim(SemaphoreCount, SemaphoreCount);
            m_storeUnprocessedIds = m_type == ParsingType.TypeByList || m_type == ParsingType.TypeByWoWHeadFilter;
            if (m_storeUnprocessedIds)
                m_badIds = new Queue<uint>();

            PageDownloadingComplete += onPageDownloadingComplete;
        }
开发者ID:Lordron,项目名称:WoWHead-data-parser,代码行数:19,代码来源:Worker.cs

示例3: FindServicePoint

		public static ServicePoint FindServicePoint (Uri address, IWebProxy proxy)
		{
			if (address == null)
				throw new ArgumentNullException ("address");

			RecycleServicePoints ();
			
			bool usesProxy = false;
			bool useConnect = false;
			if (proxy != null && !proxy.IsBypassed(address)) {
				usesProxy = true;
				bool isSecure = address.Scheme == "https";
				address = proxy.GetProxy (address);
				if (address.Scheme != "http" && !isSecure)
					throw new NotSupportedException ("Proxy scheme not supported.");

				if (isSecure && address.Scheme == "http")
					useConnect = true;
			} 

			address = new Uri (address.Scheme + "://" + address.Authority);
			
			ServicePoint sp = null;
			lock (servicePoints) {
				SPKey key = new SPKey (address, useConnect);
				sp = servicePoints [key] as ServicePoint;
				if (sp != null)
					return sp;

				if (maxServicePoints > 0 && servicePoints.Count >= maxServicePoints)
					throw new InvalidOperationException ("maximum number of service points reached");

				string addr = address.ToString ();
#if NET_2_1
				int limit = defaultConnectionLimit;
#else
				int limit = (int) manager.GetMaxConnections (addr);
#endif
				sp = new ServicePoint (address, limit, maxServicePointIdleTime);
				sp.Expect100Continue = expectContinue;
				sp.UseNagleAlgorithm = useNagle;
				sp.UsesProxy = usesProxy;
				sp.UseConnect = useConnect;
				sp.SetTcpKeepAlive (tcp_keepalive, tcp_keepalive_time, tcp_keepalive_interval);
				servicePoints.Add (key, sp);
			}
			
			return sp;
		}
开发者ID:MelanieT,项目名称:mono,代码行数:49,代码来源:ServicePointManager.cs

示例4: ServicePointConfigurator

            internal ServicePointConfigurator(ServicePoint sp, IConfigSectionNode node)
            {
                this.ServicePoint = sp;
                  sp.BindIPEndPointDelegate += bindIPEndPoint;
                  ConfigAttribute.Apply(this, node);

                  if (node.AttrByName(CONFIG_TCP_KEEPALIVE_ENABLED_ATTR).ValueAsBool())
                  {
                sp.SetTcpKeepAlive(
                  true,
                  node.AttrByName(CONFIG_TCP_KEEPALIVE_TIME_MS_ATTR).ValueAsInt(),
                  node.AttrByName(CONFIG_TCP_KEEPALIVE_INTERVAL_MS_ATTR).ValueAsInt());
                  }
            }
开发者ID:itadapter,项目名称:nfx,代码行数:14,代码来源:ServicePointManagerConfigurator.cs

示例5: Parser

        public void Parser(PageParser parser)
        {
            if (parser == null)
                throw new ArgumentNullException("parser");

            _parser = parser;

            _address = new Uri(string.Format("http://{0}wowhead.com/", _locales[parser.Locale]));
            ServicePointManager.DefaultConnectionLimit = SemaphoreCount * 10;
            _service = ServicePointManager.FindServicePoint(_address);
            {
                _service.SetTcpKeepAlive(true, 100000, 100000);
            }
            _address = new Uri(_address, parser.Address);
        }
开发者ID:Dekadencee,项目名称:WoWHead-data-parser,代码行数:15,代码来源:Worker.cs


注:本文中的System.Net.ServicePoint.SetTcpKeepAlive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。