Export (0) Print
Expand All

ServicePoint.ReceiveBufferSize Property

Gets or sets the size of the receiving buffer for the socket used by this ServicePoint.

Namespace:  System.Net
Assembly:  System (in System.dll)

public int ReceiveBufferSize { get; set; }

Property Value

Type: System.Int32
A Int32 that contains the size, in bytes, of the receive buffer. The default is 8192.

ExceptionCondition
ArgumentOutOfRangeException

The value specified for a set operation is greater than MaxValue.

For additional information, see ReceiveBufferSize.

The following code example sets the value of this property.


using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;

namespace Examples.System.Net
{
    public class ServicePointExample
    {
        // Pass in the name of the Web page to retrieve.
        public static void Main (string[] args)
        {
            string page;
            if (args == null || args.Length == 0 || args[0].Length == 0)
            {
                page = "http://www.contoso.com/default.html";
            }
            else
            {
                page = args[0];
            }
            // Create the request.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create (page);
            // Get the service point that handles the request's socket connection.
            ServicePoint point = request.ServicePoint;
            // Set the receive buffer size on the underlying socket.
            point.ReceiveBufferSize = 2048;
            // Set the connection lease timeout to infinite.
            point.ConnectionLeaseTimeout = Timeout.Infinite;
            // Send the request.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
            Stream responseStream = response.GetResponseStream ();
            StreamReader s = new StreamReader (responseStream);
            // Display the response.
            Console.WriteLine (s.ReadToEnd ());
            s.Close();
            responseStream.Close();
            response.Close();
        }
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft