Description





Description

The ServicePoint class handles connections to a resource based on the host information passed in the Uniform Resource Identifier (URI) of the resource. The initial connection to the host determines the information the ServicePoint maintains, which is then shared by all subsequent requests for resources residing on the host.

[Note: ServicePoint instances are created and managed by the ServicePointManager class. The maximum number of ServicePoint instances is set by the ServicePointManager.MaxServicePoints property. A System.Net.ServicePoint instance that is not connected to any host is idle. An idle ServicePoint is managed by the ServicePointManager only until it has been idle longer than the time specified in its ServicePoint.MaxIdleTime property. After a.ServicePoint instance exceeds the ServicePoint.MaxIdleTime, it is released by the service point manager and subsequently freed. The default value of ServicePoint.MaxIdleTime is set by the ServicePointManager.MaxServicePointIdleTime property.]

Example

using System;

using System.Net;



public class ServicePointSample

{

    public static void Main()

    {

        try

        {

            String target = "http://www.microsoft.com/";

            HttpWebRequest req = (HttpWebRequest)

                WebRequest.Create(target);

            HttpWebResponse result = (HttpWebResponse)req.GetResponse();

            result.Close();

            ServicePoint sp = req.ServicePoint;

            Console.WriteLine("ServicePoint.Address = {0}",

                sp.Address);

            Console.WriteLine("ServicePoint.ConnectionName = {0}",

                sp.ConnectionName);

            Console.WriteLine("ServicePoint.ConnectionLimit = {0}",

                sp.ConnectionLimit);

            Console.WriteLine("ServicePoint.ProtocolVersion = {0}",

                sp.ProtocolVersion);

            Console.WriteLine("ServicePoint.CurrentConnections = {0}",

                sp.CurrentConnections);

            Console.WriteLine("ServicePoint.SupportsPipelining = {0}",

                sp.SupportsPipelining);

            Console.WriteLine("ServicePoint.MaxIdleTime = {0}",

                sp.MaxIdleTime);

            Console.WriteLine("ServicePoint.IdleSince = {0}",

                sp.IdleSince);

        }

        catch (Exception e)

        {

            Console.WriteLine("*ERROR: " + e.Message);

        }

        Console.WriteLine();

        Console.WriteLine();

        Console.WriteLine("Press Enter to continue");

        Console.ReadLine();

    }

}


The output is


ServicePoint.Address = http://www.microsoft.com/

ServicePoint.ConnectionName = http

ServicePoint.ConnectionLimit = 2

ServicePoint.ProtocolVersion = 1.1

ServicePoint.CurrentConnections = 0

ServicePoint.SupportsPipelining = True

ServicePoint.MaxIdleTime = 900000

ServicePoint.IdleSince = 2/13/2005 10:52:34 AM





Press Enter to continue



     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows