本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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());
}
}
示例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);
}