Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ServicePoint.ConnectionLimit Property

Definition

Namespace:
System.Net
Assemblies:
netstandard.dll, System.Net.Requests.dll
Assemblies:
netstandard.dll, System.Net.ServicePoint.dll
Assembly:
System.Net.ServicePoint.dll
Assembly:
System.dll
Assembly:
netstandard.dll
Source:
ServicePoint.cs
Source:
ServicePoint.cs
Source:
ServicePoint.cs
Source:
ServicePoint.cs
Source:
ServicePoint.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets or sets the maximum number of connections allowed on this ServicePoint object.

public:
 property int ConnectionLimit { int get(); void set(int value); };
public int ConnectionLimit { get; set; }
member this.ConnectionLimit : int with get, set
Public Property ConnectionLimit As Integer

Property Value

The maximum number of connections allowed on this ServicePoint object.

Exceptions

The connection limit is equal to or less than 0.

Examples

The following code example uses the ConnectionLimit property to check the maximum number of connections that the ServicePoint object can make to the specified Uniform Resource Identifier (URI).

Console.WriteLine("ConnectionName = " + sp.ConnectionName);

// Display the maximum number of connections allowed on this
// ServicePoint instance.
Console.WriteLine("ConnectionLimit = " + sp.ConnectionLimit);

// Display the number of connections associated with this
// ServicePoint instance.
Console.WriteLine("CurrentConnections = " + sp.CurrentConnections);
Console.WriteLine(("ConnectionName = " + sp.ConnectionName))

' Display the maximum number of connections allowed on this 
' ServicePoint instance.
Console.WriteLine(("ConnectionLimit = " + sp.ConnectionLimit.ToString()))

' Display the number of connections associated with this 
' ServicePoint instance.
Console.WriteLine(("CurrentConnections = " + sp.CurrentConnections.ToString()))

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

The ConnectionLimit property sets the maximum number of connections that the ServicePoint object can make to an Internet resource. The value of the ConnectionLimit property is set to the value of the ServicePointManager.DefaultConnectionLimit property when the ServicePoint object is created; subsequent changes to DefaultConnectionLimit have no effect on existing ServicePoint objects.

The connection limit doesn't apply to proxied connections or proxy tunnels.

Note

Since .NET 9, this property maps to SocketsHttpHandler.MaxConnectionsPerServer. However, handlers are not being reused between requests so it doesn't have any meaningful impact.

Applies to

See also


Feedback

Was this page helpful?