System.Net.ServicePointManager Class

Assembly: System.dll
Namespace: System.Net
Summary
Manages the collection of ServicePoint instances.
C# Syntax:
public class ServicePointManager
Remarks
ServicePointManager is a static class used to create, maintain, and delete instances of the ServicePoint class.

When an application requests a connection to an Internet resource URI through the ServicePointManager, the ServicePointManager returns a ServicePoint instance containing connection information for the host identified by the URI. If there is an existing ServicePoint for that host, the ServicePointManager returns the existing ServicePoint, otherwise the ServicePointManager creates a new ServicePoint instance.

Example
The following example creates a ServicePoint instance for connections to the URI www.contoso.com .
Uri myUri = new Uri("http://www.contoso.com/");
 
 ServicePoint mySP = ServicePointManager.FindServicePoint(myUri);
   

    
See also:
System.Net Namespace

System.Net.ServicePointManager Member List:

Public Fields
DefaultNonPersistentConnectionLimit The default number of nonpersistent connections (4) allowed on a ServicePoint connected to an HTTP/1.0 or later server. This field is constant.
DefaultPersistentConnectionLimit The default number of persistent connections (2) allowed on a ServicePoint connected to an HTTP/1.1 or later server. This field is constant.
Public Properties
DefaultConnectionLimit Read-write

The maximum number of concurrent connections allowed by a ServicePoint instance.
MaxServicePointIdleTime Read-write

Gets or sets the maximum idle time of a ServicePoint instance.
MaxServicePoints Read-write

Gets or sets the maximum number of ServicePoint instances to maintain at any time.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
FindServicePoint Overloaded:
FindServicePoint(Uri address)

Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified Uri.
FindServicePoint Overloaded:
FindServicePoint(string uriString, IWebProxy proxy)

Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified URI.
FindServicePoint Overloaded:
FindServicePoint(Uri address, IWebProxy proxy)

Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified Uri instance.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Net.ServicePointManager Member Details

Field: DefaultNonPersistentConnectionLimit
Summary
The default number of nonpersistent connections (4) allowed on a ServicePoint connected to an HTTP/1.0 or later server. This field is constant.
C# Syntax:
public const int DefaultNonPersistentConnectionLimit;

Return to top


Field: DefaultPersistentConnectionLimit
Summary
The default number of persistent connections (2) allowed on a ServicePoint connected to an HTTP/1.1 or later server. This field is constant.
C# Syntax:
public const int DefaultPersistentConnectionLimit;

Return to top


Property: DefaultConnectionLimit (read-write)
Summary
The maximum number of concurrent connections allowed by a ServicePoint instance.
C# Syntax:
public static int DefaultConnectionLimit {get; set;}
Exceptions
Exception Type Condition
ArgumentOutOfRangeException ServicePointManager.DefaultConnectionLimit is less than zero.
Remarks
The ServicePointManager.DefaultConnectionLimit property sets the default maximum number of concurrent connections that the ServicePointManager assigns to the ServicePoint.ConnectionLimit property when creating ServicePoint instances.

Changing the ServicePointManager.DefaultConnectionLimit property has no effect on existing ServicePoint instances; it affects only ServicePoint instances that are initialized after the change.

Return to top


Property: MaxServicePointIdleTime (read-write)
Summary
Gets or sets the maximum idle time of a ServicePoint instance.
C# Syntax:
public static int MaxServicePointIdleTime {get; set;}
Exceptions
Exception Type Condition
ArgumentOutOfRangeException ServicePointManager.MaxServicePointIdleTime is less than -2 or greater than Int32.MaxValue
Remarks
The ServicePointManager.MaxServicePointIdleTime property sets the maximum idle time that the ServicePointManager assigns to the ServicePoint.MaxIdleTime property when creating ServicePoint instances. Changes to this value will affect only ServicePoint instances that are initialized after the value is changed.

After a ServicePoint has been idle for the time specified in ServicePoint.MaxIdleTime, it is eligible for garbage collection. A ServicePoint is idle when the list of connections associated with the ServicePoint is empty.

Default value is 900,000 milliseconds (15 minutes).

Return to top


Property: MaxServicePoints (read-write)
Summary
Gets or sets the maximum number of ServicePoint instances to maintain at any time.
C# Syntax:
public static int MaxServicePoints {get; set;}
Remarks
When you reduce the ServicePointManager.MaxServicePoints property below the number of ServicePoint instances currently in existence, the ServicePointManager deletes the ServicePoint instances with the longest idle times. If the number of ServicePoint instances with active connections is greater than the value of ServicePointManager.MaxServicePoints, the ServicePointManager will delete the ServicePoint instances as they become idle.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~ServicePointManager();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: FindServicePoint(
   Uri address
)
Summary
Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified Uri.
C# Syntax:
public static ServicePoint FindServicePoint(
   Uri address
);
Parameters:

address

The Uri of the Internet resource to contact.

Return Value:
The ServicePoint that manages communications for the request.
Exceptions
Exception Type Condition
ArgumentNullException address is null.
InvalidOperationException The maximum number of service points defined in ServicePointManager.MaxServicePoints has been reached.
Remarks
The ServicePointManager.FindServicePoint method returns the ServicePoint instance associated with the specified Internet host name. If no ServicePoint exists for that host, the ServicePointManager creates one.

Return to top


Overloaded Method: FindServicePoint(
   string uriString,
   IWebProxy proxy
)
Summary
Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified URI.
C# Syntax:
public static ServicePoint FindServicePoint(
   string uriString,
   IWebProxy proxy
);
Parameters:

uriString

The URI of the Internet resource to be contacted.

proxy

Proxy data for this request.

Return Value:
The ServicePoint that manages communications for the request.
Exceptions
Exception Type Condition
UriFormatException The URI specified in uriString is invalid.
InvalidOperationException The maximum number of service points defined in ServicePointManager.MaxServicePoints has been reached.
Remarks
The ServicePointManager.FindServicePoint method returns the ServicePoint instance associated with the specified Internet host name. If no ServicePoint exists for that host, the ServicePointManager creates one.
See also:
Uri

Return to top


Overloaded Method: FindServicePoint(
   Uri address,
   IWebProxy proxy
)
Summary
Finds an existing ServicePoint or creates a new ServicePoint to manage communications with the specified Uri instance.
C# Syntax:
public static ServicePoint FindServicePoint(
   Uri address,
   IWebProxy proxy
);
Parameters:

address

A Uri instance containing the address of the Internet resource to contact.

proxy

Proxy data for this request.

Return Value:
The ServicePoint that manages communications for the request.
Exceptions
Exception Type Condition
ArgumentNullException address is null.
InvalidOperationException The maximum number of service points defined in ServicePointManager.MaxServicePoints has been reached.
Remarks
The ServicePointManager.FindServicePoint method returns the ServicePoint instance associated with the specified Internet host name. If no ServicePoint exists for that host, the ServicePointManager creates one.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.