2009-12-18 103 views
3

有人可以解釋一下ServicePointManager.FindServicePoint的用途嗎?我一直在編寫一些代碼來與C#中的代理一起工作,並且已經看到了在這方面可能有用的指標,但是看不出爲什麼或者如何。這個類(ServicePointManager)或方法(ServicePointManager.FindServicePoint)應該如何使用(或何時)?什麼是ServicePointManager.FindServicePoint用於?

謝謝。

回答

3

ServicePointManager.FindServicePoint(...)方法將幫助您獲取已在配置文件中指定的ServicePoint對象。

讓我們說,這是你的配置文件:

<configuration> 
<system.net> 
    <connectionManagement> 
    <add address="http://www.contoso.com" maxconnection="2" /> 
    <add address="192.168.1.2" maxconnection="4" /> 
    <add address="*" maxconnection="1" /> 
    </connectionManagement> 
</system.net> 
</configuration> 

此代碼將檢索 「http://www.microsoft.comServicePoint

ServicePoint sp1 = ServicePointManager.FindServicePoint(new Uri("http://www.microsoft.com")); 

你可以閱讀所有關於它here