ServicePointManager 類別

定義

管理 ServicePoint 物件的集合。

public ref class ServicePointManager
public class ServicePointManager
type ServicePointManager = class
Public Class ServicePointManager
繼承
ServicePointManager

範例

下列程式碼範例會 ServicePoint 建立 物件,以連線至 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 靜態類別。

當應用程式透過 物件要求連線到網際網路資源統一資源識別元 (URI) ServicePointManager 時,會 ServicePointManager 傳回 ServicePoint 物件,其中包含 URI 所識別主機和配置的連接資訊。 如果該主機和配置有現有的 ServicePoint 物件,物件 ServicePointManager 會傳回現有的 ServicePoint 物件, ServicePointManager 否則物件會建立新的 ServicePoint 物件。

.NET Framework 4.6 包含新的安全性功能,可封鎖連線不安全的加密和雜湊演算法。 透過 API 使用 TLS/SSL 的應用程式,例如 HttpClientHttpWebRequest 、、 FtpWebRequestSmtpClientSslStream 等和目標.NET Framework 4.6,預設會取得更安全的行為。

開發人員可能會想要退出此行為,以維持其現有 SSL3 服務或 TLS w/ RC4 服務的互通性。 本文 說明如何修改程式碼,以便停用新的行為。

重要

不建議您將 類別用於 ServicePointManager 新的開發。 請改用 System.Net.Http.HttpClient 類別。

欄位

DefaultNonPersistentConnectionLimit

預設的非持續連線數目 (4),是連接至 HTTP/1.0 (含) 以後版本伺服器之 ServicePoint 物件上所允許的連線數目。 這個欄位是常數,但在 .NET Framework 2.0 之後已不再使用。

DefaultPersistentConnectionLimit

預設的持續連線數目 (2),是連接至 HTTP/1.1 (含) 以後版本伺服器之 ServicePoint 物件上所允許的連線數目。 這個欄位是常數,如果尚未直接或透過組態設定 DefaultConnectionLimit 屬性的值,則會使用此欄位初始化 DefaultConnectionLimit 屬性。

屬性

CertificatePolicy
已過時。
已過時。

取得或設定伺服器憑證原則。

CheckCertificateRevocationList

取得或設定 Boolean 值,指出是否根據憑證授權撤銷清單檢查憑證。

ClientCipherSuitesCallback
DefaultConnectionLimit

取得或設定 ServicePoint 物件所允許的同時連線最大數。

DnsRefreshTimeout

取得或設定值,指出有效的網域名稱服務 (DNS) 解析時間長度。

EnableDnsRoundRobin

取得或設定值,指出網域名稱服務 (DNS) 解析是否會在適用的網際網路通訊協定 (IP) 位址間循環。

EncryptionPolicy

取得這個 ServicePointManager 執行個體的 EncryptionPolicy

Expect100Continue

取得或設定 Boolean 值,用以判斷是否有使用 100-Continue 行為。

MaxServicePointIdleTime

取得或設定 ServicePoint 物件的最大閒置時間。

MaxServicePoints

取得或設定要在任何時間維護 ServicePoint 物件的最大數。

ReusePort

將這個屬性值設定為 true 將會讓來自 HttpWebRequest 的所有連出 TCP 連線使用通訊端上的原生通訊端選項 SO_REUSE_UNICASTPORT。 這會導致共用底層連出連接埠。 對於短時間內有大量連出連線的案例,這非常實用,但應用程式可能會遇到連接埠耗盡的問題。

SecurityProtocol

取得或設定由 ServicePointManager 物件管理的 ServicePoint 物件所使用的安全性通訊協定。

ServerCertificateValidationCallback

取得或設定用來驗證伺服器憑證的回呼。

ServerCipherSuitesCallback
UseNagleAlgorithm

判斷由這個 ServicePointManager 物件所管理的服務點是否使用 Nagle 演算法。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindServicePoint(String, IWebProxy)
已過時。

尋找現有 ServicePoint 物件或建立新的 ServicePoint 物件,以管理對指定之統一資源識別元 (URI) 的通訊。

FindServicePoint(Uri)
已過時。

尋找現有 ServicePoint 物件或建立新的 ServicePoint 物件,以管理對指定之 Uri 物件的通訊。

FindServicePoint(Uri, IWebProxy)
已過時。

尋找現有 ServicePoint 物件或建立新的 ServicePoint 物件,以管理對指定之 Uri 物件的通訊。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
SetTcpKeepAlive(Boolean, Int32, Int32)

啟用或停用 TCP 連線的 Keep-Alive 選項。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱