ServicePointManager.FindServicePoint メソッド

定義

要求を処理するための通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい ServicePoint オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communication for this request.

オーバーロード

FindServicePoint(Uri, IWebProxy)

指定した Uri オブジェクトとの通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい ServicePoint オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uri object.

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(String, IWebProxy)

指定した URI (Uniform Resource Identifier) との通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい ServicePoint オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uniform Resource Identifier (URI).

FindServicePoint(Uri, IWebProxy)

指定した Uri オブジェクトとの通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい ServicePoint オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uri object.

public:
 static System::Net::ServicePoint ^ FindServicePoint(Uri ^ address, System::Net::IWebProxy ^ proxy);
public static System.Net.ServicePoint FindServicePoint (Uri address, System.Net.IWebProxy proxy);
static member FindServicePoint : Uri * System.Net.IWebProxy -> System.Net.ServicePoint
Public Shared Function FindServicePoint (address As Uri, proxy As IWebProxy) As ServicePoint

パラメーター

address
Uri

接続先のインターネット リソースのアドレスを格納している Uriオブジェクト。A Uri object that contains the address of the Internet resource to contact.

proxy
IWebProxy

この要求に対して使用するプロキシ データ。The proxy data for this request.

戻り値

要求を処理するための通信を管理する ServicePoint オブジェクト。The ServicePoint object that manages communications for the request.

例外

addressnull です。address is null.

ServicePoint で定義されている MaxServicePoints オブジェクトの最大数に達しました。The maximum number of ServicePoint objects defined in MaxServicePoints has been reached.

注釈

FindServicePoint メソッドは、指定されたインターネットホスト名に関連付けられた ServicePoint オブジェクトを返します。The FindServicePoint method returns the ServicePoint object associated with the specified Internet host name. そのホストに ServicePoint オブジェクトが存在しない場合、ServicePointManager オブジェクトによって作成されます。If no ServicePoint object exists for that host, the ServicePointManager object creates one.

こちらもご覧ください

FindServicePoint(Uri)

指定した ServicePoint オブジェクトとの通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい Uri オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uri object.

public:
 static System::Net::ServicePoint ^ FindServicePoint(Uri ^ address);
public static System.Net.ServicePoint FindServicePoint (Uri address);
static member FindServicePoint : Uri -> System.Net.ServicePoint
Public Shared Function FindServicePoint (address As Uri) As ServicePoint

パラメーター

address
Uri

接続先のインターネット リソースの Uri オブジェクト。The Uri object of the Internet resource to contact.

戻り値

要求を処理するための通信を管理する ServicePoint オブジェクト。The ServicePoint object that manages communications for the request.

例外

addressnull です。address is null.

ServicePoint で定義されている MaxServicePoints オブジェクトの最大数に達しました。The maximum number of ServicePoint objects defined in MaxServicePoints has been reached.

注釈

FindServicePoint メソッドは、指定されたインターネットホスト名に関連付けられた ServicePoint オブジェクトを返します。The FindServicePoint method returns the ServicePoint object associated with the specified Internet host name. そのホストに ServicePoint オブジェクトが存在しない場合、ServicePointManager オブジェクトによって作成されます。If no ServicePoint object exists for that host, the ServicePointManager object creates one.

こちらもご覧ください

FindServicePoint(String, IWebProxy)

指定した URI (Uniform Resource Identifier) との通信を管理するには、既存の ServicePoint オブジェクトを検出するか、新しい ServicePoint オブジェクトを作成します。Finds an existing ServicePoint object or creates a new ServicePoint object to manage communications with the specified Uniform Resource Identifier (URI).

public:
 static System::Net::ServicePoint ^ FindServicePoint(System::String ^ uriString, System::Net::IWebProxy ^ proxy);
public static System.Net.ServicePoint FindServicePoint (string uriString, System.Net.IWebProxy proxy);
static member FindServicePoint : string * System.Net.IWebProxy -> System.Net.ServicePoint
Public Shared Function FindServicePoint (uriString As String, proxy As IWebProxy) As ServicePoint

パラメーター

uriString
String

接続先のインターネット リソースの URI。The URI of the Internet resource to be contacted.

proxy
IWebProxy

この要求に対して使用するプロキシ データ。The proxy data for this request.

戻り値

要求を処理するための通信を管理する ServicePoint オブジェクト。The ServicePoint object that manages communications for the request.

例外

uriString で指定した URI が無効です。The URI specified in uriString is invalid.

ServicePoint で定義されている MaxServicePoints オブジェクトの最大数に達しました。The maximum number of ServicePoint objects defined in MaxServicePoints has been reached.

次のコード例は、このメソッドを呼び出して ServicePoint オブジェクトにアクセスする方法を示しています。The following code example demonstrates calling this method to access a ServicePoint object.

int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   int port = 80;
   
   // Define a regular expression to parse the user's input.
   // This is a security check. It allows only
   // alphanumeric input strings between 2 to 40 characters long.
   Regex^ rex = gcnew Regex( "^[a-zA-Z]\\w{1,39}$" );
   if ( args->Length < 2 )
   {
      showUsage();
      return  -1;
   }

   String^ proxy = args[ 1 ];
   if ( (rex->Match(proxy))->Success != true )
   {
      Console::WriteLine( "Input string format not allowed." );
      return  -1;
   }

   String^ proxyAdd = String::Format( "http://{0}:{1}", proxy, port );
   
   // Create a proxy object.  
   WebProxy^ DefaultProxy = gcnew WebProxy( proxyAdd,true );
   
   // Set the proxy that all HttpWebRequest instances use.
   WebRequest::DefaultWebProxy = DefaultProxy;
   
   // Get the base interface for proxy access for the 
   // WebRequest-based classes.
   IWebProxy^ Iproxy = WebRequest::DefaultWebProxy;

   
   // Set the maximum number of ServicePoint instances to 
   // maintain. If a ServicePoint instance for that host already 
   // exists when your application requests a connection to
   // an Internet resource, the ServicePointManager object
   // returns this existing ServicePoint instance. If none exists 
   // for that host, it creates a new ServicePoint instance.
   ServicePointManager::MaxServicePoints = 4;
   
   // Set the maximum idle time of a ServicePoint instance to 10 seconds.
   // After the idle time expires, the ServicePoint object is eligible for
   // garbage collection and cannot be used by the ServicePointManager.
   ServicePointManager::MaxServicePointIdleTime = 10000;
   
   ServicePointManager::UseNagleAlgorithm = true;
   ServicePointManager::Expect100Continue = true;
   ServicePointManager::CheckCertificateRevocationList = true;
   ServicePointManager::DefaultConnectionLimit = ServicePointManager::DefaultPersistentConnectionLimit;
   
   // Create the Uri object for the resource you want to access.
   Uri^ MS = gcnew Uri( "http://msdn.microsoft.com/" );
   
   // Use the FindServicePoint method to find an existing 
   // ServicePoint object or to create a new one.   
   ServicePoint^ servicePoint = ServicePointManager::FindServicePoint( MS, Iproxy );
   ShowProperties( servicePoint );
   int hashCode = servicePoint->GetHashCode();
   Console::WriteLine( "Service point hashcode: {0}", hashCode );
   
   // Make a request with the same scheme identifier and host fragment
   // used to create the previous ServicePoint object.
   makeWebRequest( hashCode, "http://msdn.microsoft.com/library/" );
}

public static void Main(string[] args)
{
    int port = 80;

    // Define a regular expression to parse the user's input.
    // This is a security check. It allows only
    // alphanumeric input strings between 2 to 40 characters long.
    Regex rex = new Regex(@"^[a-zA-Z]\w{1,39}$");

    if (args.Length < 1)
    {
        showUsage();
        return;
    }
    string proxy = args[0];

    if ((rex.Match(proxy)).Success != true)
    {
        Console.WriteLine("Input string format not allowed.");
        return;
    }
    string proxyAdd = "http://" + proxy + ":" + port;

    // Create a proxy object.  
    WebProxy DefaultProxy = new WebProxy(proxyAdd, true);

    // Set the proxy that all HttpWebRequest instances use.
    WebRequest.DefaultWebProxy = DefaultProxy;

    // Get the base interface for proxy access for the 
    // WebRequest-based classes.
    IWebProxy Iproxy = WebRequest.DefaultWebProxy;

    // Set the maximum number of ServicePoint instances to 
    // maintain. If a ServicePoint instance for that host already 
    // exists when your application requests a connection to
    // an Internet resource, the ServicePointManager object
    // returns this existing ServicePoint instance. If none exists 
    // for that host, it creates a new ServicePoint instance.
    ServicePointManager.MaxServicePoints = 4;

    // Set the maximum idle time of a ServicePoint instance to 10 seconds.
    // After the idle time expires, the ServicePoint object is eligible for
    // garbage collection and cannot be used by the ServicePointManager object.
    ServicePointManager.MaxServicePointIdleTime = 10000;

    ServicePointManager.UseNagleAlgorithm = true;
    ServicePointManager.Expect100Continue = true;
    ServicePointManager.CheckCertificateRevocationList = true;
    ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit;
    // Create the Uri object for the resource you want to access.
    Uri MS = new Uri("http://msdn.microsoft.com/");

    // Use the FindServicePoint method to find an existing 
    // ServicePoint object or to create a new one.  
    ServicePoint servicePoint = ServicePointManager.FindServicePoint(MS, Iproxy);

    ShowProperties(servicePoint);

    int hashCode = servicePoint.GetHashCode();

    Console.WriteLine("Service point hashcode: " + hashCode);

    // Make a request with the same scheme identifier and host fragment
    // used to create the previous ServicePoint object.
    makeWebRequest(hashCode, "http://msdn.microsoft.com/library/");
}
' This is the program entry point. It allows the user to enter 
' a server name that is used to locate its current homepage.
Public Shared Sub Main(ByVal args() As String)
    Dim proxy As String = Nothing
    Dim port As Integer = 80

    ' Define a regular expression to parse the user's input.
    ' This is a security check. It allows only
    ' alphanumeric input strings between 2 to 40 characters long.
    Dim rex As New Regex("^[a-zA-Z]\w{1,39}$")

    If args.Length = 0 Then
        ' Show how to use this program.
        showUsage()
        Return
    End If

    proxy = args(0)
    If (Not (rex.Match(proxy)).Success) Then
        Console.WriteLine("Input string format not allowed.")
        Return
    End If

    ' Create a proxy object.  
    Dim proxyAdd As String
    proxyAdd = "http://" + proxy + ":" + port.ToString()


    Dim DefaultProxy As New WebProxy(proxyAdd, True)

    ' Set the proxy that all HttpWebRequest instances use.
    WebRequest.DefaultWebProxy = DefaultProxy


    ' Get the base interface for proxy access for the 
    ' WebRequest-based classes.
    Dim Iproxy As IWebProxy = WebRequest.DefaultWebProxy

    ' Set the maximum number of ServicePoint instances to maintain.
    ' Note that, if a ServicePoint instance for that host already 
    ' exists when your application requests a connection to
    ' an Internet resource, the ServicePointManager object
    ' returns this existing ServicePoint. If none exists 
    ' for that host, it creates a new ServicePoint instance.
    ServicePointManager.MaxServicePoints = 4

    ' Set the maximum idle time of a ServicePoint instance to 10 seconds.
    ' After the idle time expires, the ServicePoint object is eligible for
    ' garbage collection and cannot be used by the ServicePointManager.
    ServicePointManager.MaxServicePointIdleTime = 10000


    ServicePointManager.UseNagleAlgorithm = True
    ServicePointManager.Expect100Continue = True
    ServicePointManager.CheckCertificateRevocationList = True
    ServicePointManager.DefaultConnectionLimit = _
        ServicePointManager.DefaultPersistentConnectionLimit
    ' Create the Uri object for the resource you want to access.
    Dim MS As New Uri("http://msdn.microsoft.com/")

    ' Use the FindServicePoint method to find an existing 
    ' ServicePoint object or to create a new one.   
    Dim servicePoint As ServicePoint = ServicePointManager.FindServicePoint(MS, Iproxy)
    ShowProperties(servicePoint)
    Dim hashCode As Integer = servicePoint.GetHashCode()
    Console.WriteLine(("Service point hashcode: " + hashCode.ToString()))

    ' Make a request with the same scheme identifier and host fragment
    ' used to create the previous ServicePoint object.
    makeWebRequest(hashCode, "http://msdn.microsoft.com/library/")

End Sub

注釈

FindServicePoint メソッドは、指定されたインターネットホスト名に関連付けられた ServicePoint オブジェクトを返します。The FindServicePoint method returns the ServicePoint object associated with the specified Internet host name. そのホストに ServicePoint オブジェクトが存在しない場合、ServicePointManager オブジェクトによって作成されます。If no ServicePoint object exists for that host, the ServicePointManager object creates one.

こちらもご覧ください

適用対象