System.Net.ServicePointManager Class

public class ServicePointManager

Base Types

Object
  ServicePointManager

Assembly

System

Library

Networking

Summary

Manages ServicePoint instances.

Description

ServicePointManager creates, maintains, and deletes ServicePoint instances.

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

See Also

System.Net Namespace

Members

ServicePointManager Methods

ServicePointManager.FindServicePoint(System.Uri) Method
ServicePointManager.FindServicePoint(System.String, System.Net.IWebProxy) Method
ServicePointManager.FindServicePoint(System.Uri, System.Net.IWebProxy) Method

ServicePointManager Fields

ServicePointManager.DefaultNonPersistentConnectionLimit Field
ServicePointManager.DefaultPersistentConnectionLimit Field

ServicePointManager Properties

ServicePointManager.DefaultConnectionLimit Property
ServicePointManager.MaxServicePointIdleTime Property
ServicePointManager.MaxServicePoints Property


ServicePointManager.FindServicePoint(System.Uri) Method

public static ServicePoint FindServicePoint(Uri address);

Summary

Finds an existing ServicePoint or creates a new ServicePoint to connect to the specified host.

Parameters

address
A Uri containing the Internet host to contact.

Return Value

A ServicePoint that connects to the host identified in address .

Exceptions

Exception TypeCondition
ArgumentNullExceptionaddress is null .
InvalidOperationExceptionThe maximum number of service points defined in System.Net.ServicePointManager.MaxServicePoints has been reached and there is no service point that connects to the specified host.

Description

This method is identical to System.Net.ServicePointManager.FindServicePoint(System.Uri)(address, System.Net.GlobalProxySelection.GetEmptyWebProxy).

If no ServicePoint exists for the host named in address , the ServicePointManager attempts to create one.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.FindServicePoint(System.String, System.Net.IWebProxy) Method

public static ServicePoint FindServicePoint(string uriString, IWebProxy proxy);

Summary

Finds an existing ServicePoint or creates a new ServicePoint to connect to the specified host.

Parameters

uriString
A String containing a URI that names the host to contact.
proxy
A IWebProxy that represents a proxy server to access.

Return Value

A ServicePoint that connects to the host identified in uriString .

Exceptions

Exception TypeCondition
ArgumentNullExceptionuriString is null .
UriFormatExceptionThe URI specified in uriString is in an invalid form.
InvalidOperationExceptionThe maximum number of service points defined in System.Net.ServicePointManager.MaxServicePoints has been reached and there is no service point that connects to the specified host.

Description

This method is identical to System.Net.ServicePointManager.FindServicePoint(System.Uri)(new Uri(uriString), proxy).

If no ServicePoint exists for the host named in uriString, the ServicePointManager attempts to create one.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.FindServicePoint(System.Uri, System.Net.IWebProxy) Method

public static ServicePoint FindServicePoint(Uri address, IWebProxy proxy);

Summary

Finds an existing ServicePoint or creates a new ServicePoint to connect to the specified host.

Parameters

address
A Uri instance containing the address of the Internet resource to contact.
proxy
A IWebProxy that represents a proxy server to access.

Return Value

A ServicePoint that connects to the host identified in address .

Exceptions

Exception TypeCondition
ArgumentNullExceptionaddress is null .
InvalidOperationExceptionThe maximum number of service points defined in System.Net.ServicePointManager.MaxServicePoints has been reached and there is no service point that connects to the specified host.

Description

If no ServicePoint exists for the System.Uri.Host specified in address , the ServicePointManager attempts to create one.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.DefaultNonPersistentConnectionLimit Field

public const int DefaultNonPersistentConnectionLimit = 4;

Summary

The default number of non-persistent connections allowed on a ServicePoint .

Description

This field is read-only.

The value of this field is 4.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.DefaultPersistentConnectionLimit Field

public const int DefaultPersistentConnectionLimit = 2;

Summary

The default number of persistent connections allowed on a ServicePoint .

Description

This field is read-only.

The value of this field is 2.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.DefaultConnectionLimit Property

public static int DefaultConnectionLimit { get; set; }

Summary

Gets or sets the maximum number of concurrent connections allowed by a ServicePoint instance.

Property Value

A Int32 containing the maximum number of concurrent connections allowed by a ServicePoint instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than or equal to zero.

Description

The System.Net.ServicePointManager.DefaultConnectionLimit property sets the default maximum number of concurrent connections that the ServicePointManager assigns to the System.Net.ServicePoint.ConnectionLimit property when creating ServicePoint instances.

[Note: Changing the System.Net.ServicePointManager.DefaultConnectionLimit property has no effect on existing ServicePoint instances; it affects only ServicePoint instances that are initialized after the change.]

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.MaxServicePointIdleTime Property

public static int MaxServicePointIdleTime { get; set; }

Summary

Gets or sets the maximum amount of time a ServicePoint instance can be idle, after which resources allocated to the service point can be released.

Property Value

A Int32 containing the maximum idle time, in milliseconds, of a ServicePoint instance.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than System.Threading.Timeout.Infinite or greater than System.Int32.MaxValue

Description

A ServicePoint is idle when the list of connections associated with the ServicePoint is empty.

The System.Net.ServicePointManager.MaxServicePointIdleTime property holds the value for the maximum idle time for service points. When a ServicePoint instance is created, this value is assigned to its System.Net.ServicePoint.MaxIdleTime property. Changes to the value of this property affect only ServicePoint instances that are initialized after this property is changed.

After a ServicePoint has been idle for the time specified in System.Net.ServicePoint.MaxIdleTime , it is released by the service point manager, and any resources allocated for it are freed.

The default value of this property is implementation defined.

See Also

System.Net.ServicePointManager Class, System.Net Namespace

ServicePointManager.MaxServicePoints Property

public static int MaxServicePoints { get; set; }

Summary

Gets or sets the maximum number of ServicePoint instances managed by this class at any time.

Property Value

A Int32 containing the maximum number of ServicePoint instances to maintain.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than zero or greater than System.Int32.MaxValue

Description

If this property is set to a value that is less than 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 System.Net.ServicePointManager.MaxServicePoints, the ServicePointManager deletes ServicePoint instances as they become idle.

[Note: The default value of the System.Net.ServicePointManager.MaxServicePoints property is 0, which indicates there is no limit to the number of ServicePoint instances.]

See Also

System.Net.ServicePointManager Class, System.Net Namespace