This documentation is archived and is not being maintained.

SocketAsyncEventArgs.SetBuffer Method (Int32, Int32)

Sets the data buffer to use with an asynchronous socket method.

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

public void SetBuffer(
	int offset,
	int count
)

Parameters

offset
Type: System.Int32

The offset, in bytes, in the data buffer where the operation starts.

count
Type: System.Int32

The maximum amount of data, in bytes, to send or receive in the buffer.

ExceptionCondition
ArgumentException

There are ambiguous buffers specified. This exception occurs if the Buffer property is also not null and the BufferList property is also not null.

ArgumentOutOfRangeException

An argument was out of range. This exception occurs if the offset parameter is less than zero or greater than the length of the array in the Buffer property. This exception also occurs if the count parameter is less than zero or greater than the length of the array in the Buffer property minus the offset parameter.

The offset and count parameters can't be negative numbers. The combination of the offset and count parameters must be in bounds of the buffer array in the Buffer property.

This method sets the Count property to the count parameter and the Offset property to the offset parameter.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5 SP1, 3.0 SP1, 2.0 SP1
Show: