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
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. If the Buffer property is null, this method ignores the offset and count parameters and sets the Offset and Count properties to 0.

This method does not change the Buffer property.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft