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.comThe 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.

当应用程序通过 ServicePointManager 对象请求与 Internet 资源统一资源标识符(URI)的连接时,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 (例如 HttpClientHttpWebRequestFtpWebRequestSmtpClient、4.6 SslStream等)使用 TLS/SSL 的应用程序将获得更安全的行为。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.

字段

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 in the .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

获取此 EncryptionPolicy 实例的 ServicePointManagerGets 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

将此属性值设置为 true 会导致来自 HttpWebRequest 的所有出站 TCP 连接对套接字使用本机套接字选项 SO_REUSE_UNICASTPORT。Setting this property value to true causes all outbound TCP connections from HttpWebRequest to use the native socket option SO_REUSE_UNICASTPORT on the socket. 这使得可以共享基础传出端口。This causes the underlying outgoing ports to be shared. 这可用于在短时间内进行大量传出连接并且应用面临耗尽端口风险的情况。This is useful for scenarios where a large number of outgoing connections are made in a short time, and the app risks running out of ports.

SecurityProtocol

获取或设置由 ServicePoint 对象管理的 ServicePointManager 对象所使用的安全协议。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()

获取当前实例的 TypeGets 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()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅