ServicePointManager 类
定义
管理 ServicePoint 对象集合。Manages the collection of ServicePoint objects.
public ref class ServicePointManager
public class ServicePointManager
type ServicePointManager = class
Public Class ServicePointManager
- 继承
-
ServicePointManager
示例
下面的代码示例创建一个 ServicePoint 对象,用于连接到 URI www.contoso.com 。The following code example creates a ServicePoint object for connections to the URI www.contoso.com.
Uri^ myUri = gcnew Uri( "http://www.contoso.com/" );
ServicePoint^ mySP = ServicePointManager::FindServicePoint( myUri );
Uri myUri = new Uri("http://www.contoso.com/");
ServicePoint mySP = ServicePointManager.FindServicePoint(myUri);
Dim myUri As New Uri("http://www.contoso.com/")
Dim mySP As ServicePoint = ServicePointManager.FindServicePoint(myUri)
注解
ServicePointManager 是一个静态类,用来创建、维护和删除类的实例 ServicePoint 。ServicePointManager is a static class used to create, maintain, and delete instances of the ServicePoint class.
当应用程序请求连接到 Internet 资源统一资源标识符 (URI) 通过对象连接时 ServicePointManager ,将 ServicePointManager 返回一个 ServicePoint 对象,其中包含由 URI 标识的主机和方案的连接信息。When an application requests a connection to an Internet resource Uniform Resource Identifier (URI) through the ServicePointManager object, the ServicePointManager returns a ServicePoint object that contains connection information for the host and scheme identified by the URI. 如果存在 ServicePoint 该主机和方案的现有对象,则该 ServicePointManager 对象将返回现有 ServicePoint 对象; 否则,该对象会 ServicePointManager 创建一个新 ServicePoint 的对象。If there is an existing ServicePoint object for that host and scheme, the ServicePointManager object returns the existing ServicePoint object; otherwise, the ServicePointManager object creates a new ServicePoint object.
4.6 .NET Framework 包括一项新的安全功能,用于阻止连接的不安全密码和哈希算法。The .NET Framework 4.6 includes a new security feature that blocks insecure cipher and hashing algorithms for connections. 默认情况下,通过 api 使用 TLS/SSL (如、、、、等 HttpClient ) HttpWebRequest FtpWebRequest SmtpClient SslStream 和目标 .NET Framework 4.6 获取更安全的行为。Applications using TLS/SSL through APIs such as HttpClient, HttpWebRequest, FtpWebRequest, SmtpClient, SslStream, etc. and targeting .NET Framework 4.6 get the more-secure behavior by default.
开发人员可能需要选择退出此行为,以便与现有的 SSL3 服务或具有 RC4 服务的 TLS 保持互操作性。Developers may want to opt out of this behavior in order to maintain interoperability with their existing SSL3 services or TLS w/ RC4 services. 本文 介绍如何修改代码,以便禁用新行为。This article explains how to modify your code so that the new behavior is disabled.
重要
不建议使用 ServicePointManager 类进行新的开发。We don't recommend that you use the ServicePointManager class for new development. 而应使用 System.Net.Http.HttpClient 类。Instead, use the System.Net.Http.HttpClient class.
字段
| DefaultNonPersistentConnectionLimit |
在连接到 HTTP/1.0 或更高版本服务器的 ServicePoint 对象上允许存在的非持久性连接的默认数目 (4)。The default number of non-persistent connections (4) allowed on a ServicePoint object connected to an HTTP/1.0 or later server. 此字段为常量,但从 .NET Framework 2.0 开始不再使用。This field is constant but is no longer used as of .NET Framework 2.0. |
| DefaultPersistentConnectionLimit |
在连接到 HTTP/1.1 或更高版本服务器的 ServicePoint 对象上允许存在的持久性连接的默认数目 (2)。The default number of persistent connections (2) allowed on a ServicePoint object connected to an HTTP/1.1 or later server. 如果未以直接方式或通过配置设置 DefaultConnectionLimit 属性的值,则此字段为常量,用于初始化 DefaultConnectionLimit 属性。This field is constant and is used to initialize the DefaultConnectionLimit property if the value of the DefaultConnectionLimit property has not been set either directly or through configuration. |
属性
| CertificatePolicy |
已过时。
已过时。
获取或设置服务器证书的策略。Gets or sets policy for server certificates. |
| CheckCertificateRevocationList |
获取或设置一个 Boolean 值,该值指示是否根据证书颁发机构吊销列表检查证书。Gets or sets a Boolean value that indicates whether the certificate is checked against the certificate authority revocation list. |
| ClientCipherSuitesCallback | |
| DefaultConnectionLimit |
获取或设置 ServicePoint 对象所允许的最大并发连接数。Gets or sets the maximum number of concurrent connections allowed by a ServicePoint object. |
| DnsRefreshTimeout |
获取或设置一个值,该值指示域名服务 (DNS) 解析多长时间内视为有效。Gets or sets a value that indicates how long a Domain Name Service (DNS) resolution is considered valid. |
| EnableDnsRoundRobin |
获取或设置一个值,该值指示域名服务 (DNS) 解析是否在多个适用的 Internet 协议 (IP) 地址之间轮流进行。Gets or sets a value that indicates whether a Domain Name Service (DNS) resolution rotates among the applicable Internet Protocol (IP) addresses. |
| EncryptionPolicy |
获取此 ServicePointManager 实例的 EncryptionPolicy。Gets the EncryptionPolicy for this ServicePointManager instance. |
| Expect100Continue |
获取或设置一个 Boolean 值,该值确定是否使用 100-Continue 行为。Gets or sets a Boolean value that determines whether 100-Continue behavior is used. |
| MaxServicePointIdleTime |
获取或设置 ServicePoint 对象的最大空闲时间。Gets or sets the maximum idle time of a ServicePoint object. |
| MaxServicePoints |
获取或设置任何时候保持的最大 ServicePoint 对象数。Gets or sets the maximum number of ServicePoint objects to maintain at any time. |
| ReusePort |
将此属性值设置为 |
| SecurityProtocol |
获取或设置由 ServicePointManager 对象管理的 ServicePoint 对象所使用的安全协议。Gets or sets the security protocol used by the ServicePoint objects managed by the ServicePointManager object. |
| ServerCertificateValidationCallback |
获取或设置用于验证服务器证书的回调。Gets or sets the callback to validate a server certificate. |
| ServerCipherSuitesCallback | |
| UseNagleAlgorithm |
确定由此 ServicePointManager 对象管理的服务点是否使用 Nagle 算法。Determines whether the Nagle algorithm is used by the service points managed by this ServicePointManager object. |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| FindServicePoint(String, IWebProxy) |
查找现有的 ServicePoint 对象或创建新的 ServicePoint 对象,以管理与指定的统一资源标识符 (URI) 的通信。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uniform Resource Identifier (URI). |
| FindServicePoint(Uri) |
查找现有的 ServicePoint 对象或创建新的 ServicePoint 对象来管理与指定 Uri 对象的通信。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uri object. |
| FindServicePoint(Uri, IWebProxy) |
查找现有的 ServicePoint 对象或创建新的 ServicePoint 对象来管理与指定 Uri 对象的通信。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uri object. |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| SetTcpKeepAlive(Boolean, Int32, Int32) |
对 TCP 连接启用或禁用 keep-alive 选项。Enables or disables the keep-alive option on a TCP connection. |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |