System
2.0.0.0
4.0.0.0
System.EventArgs
System.IDisposable
The class is part of a set of enhancements to the class that provide an alternative asynchronous pattern that can be used by specialized high-performance socket applications. This class was specifically designed for network server applications that require high performance. An application can use the enhanced asynchronous pattern exclusively or only in targeted hot areas (for example, when receiving large amounts of data).
The main feature of these enhancements is the avoidance of the repeated allocation and synchronization of objects during high-volume asynchronous socket I/O. The Begin/End design pattern currently implemented by the class requires a object be allocated for each asynchronous socket operation.
In the new class enhancements, asynchronous socket operations are described by reusable objects allocated and maintained by the application. High-performance socket applications know best the amount of overlapped socket operations that must be sustained. The application can create as many of the objects that it needs. For example, if a server application needs to have 15 socket accept operations outstanding at all times to support incoming client connection rates, it can allocate 15 reusable objects for that purpose.
The pattern for performing an asynchronous socket operation with this class consists of the following steps:
-
Allocate a new context object, or get a free one from an application pool.
-
Set properties on the context object to the operation about to be performed (the completion callback method, the data buffer, the offset into the buffer, and the maximum amount of data to transfer, for example).
-
Call the appropriate socket method (xxxAsync) to initiate the asynchronous operation.
-
If the asynchronous socket method (xxxAsync) returns true, in the callback, query the context properties for completion status.
-
If the asynchronous socket method (xxxAsync) returns false, the operation completed synchronously. The context properties may be queried for the operation result.
-
Reuse the context for another operation, put it back in the pool, or discard it.
The lifetime of the new asynchronous socket operation context object is determined by references by the application code and asynchronous I/O references. It is not necessary for the application to retain a reference to an asynchronous socket operation context object after it is submitted as a parameter to one of the asynchronous socket operation methods. It will remain referenced until the completion callback returns. However it is advantageous for the application to retain the reference to the context so that it can be reused for a future asynchronous socket operation.
Represents an asynchronous socket operation.
Constructor
2.0.0.0
4.0.0.0
After calling this constructor all properties will have their default values:
-
Object references will be null
-
Properties that return an integer will return zero.
-
The property will be equal to .
-
The property will be equal to , which specifies no flags will be used.
-
The property will be equal to .
The caller must set the appropriate properties prior to passing the object to the appropriate asynchronous socket (xxxAsync) method.
Creates an empty instance.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.Socket
To be added.
This property can be used to provide an already created that will be used for an asynchronous socket accept operation. Upon completion of the accept operation, it is the socket representing the accepted connection. If not supplied (set to null) before calling the method, a new socket will be created automatically and be accessible in the completion callback with this property.
Gets or sets the socket to use or the socket created for accepting a connection with an asynchronous socket method.
Property
2.0.0.0
4.0.0.0
System.Byte[]
To be added.
This property gets the data buffer currently associated with the instance. To set the buffer, the method must be used.
This property is used with the , , , , , , and methods.
Gets the data buffer to use with an asynchronous socket method.
Property
2.0.0.0
4.0.0.0
System.Collections.Generic.IList<System.ArraySegment<System.Byte>>
To be added.
This property is used with the and methods.
This property is used to provide multiple buffers of data to be sent or to provide multiple buffers in which to store received data for an asynchronous socket operation that can send or receive data. Multiple buffers using the property are supported by the and methods.
If the property is set to a non-null value, the property must be null and is ignored by the and methods.
If the was set to a non-null value and an attempt is made to set the property to a non-null value, an exception is thrown.
If the property is set to a non-null value, the and methods will throw an .
The parameter is ignored by the and methods.
Gets or sets an array of data buffers to use with an asynchronous socket method.
Property
2.0.0.0
4.0.0.0
System.Int32
To be added.
This property provides the number of bytes transferred in an asynchronous socket operation that can receive or send data. If zero is returned from a read operation, the remote end has closed the connection.
This property is set by all asynchronous socket operations except the method.
Gets the number of bytes transferred in the socket operation.
Event
2.0.0.0
4.0.0.0
System.EventHandler<System.Net.Sockets.SocketAsyncEventArgs>
The event provides a way for client applications to complete an asynchronous socket operation. An event handler should be attached to the event within a instance when an asynchronous socket operation is initiated, otherwise the application will not be able to determine when the operation completes.
The completion callback delegates referenced by the event contains program logic to finish processing the asynchronous socket operation for the client.
When the event is signaled, the application uses the object parameter to obtain the status of the completed asynchronous socket operation.
The event used to complete an asynchronous operation.
Property
4.0.0.0
System.Exception
To be added.
In the case of a connection failure when a was specified for the property, the property will contain the exception that indicates the detailed cause of the socket error.
When an was specified for the property and a connection failure occurs, the property will be a null reference.
The property is always set in the case of a connection failure. The property contains more information about the failure if it was a failure connecting to a . If an application is only interested in whether the connect operation succeeded or failed, then the application only needs to check the property.
Gets the exception in the case of a connection failure when a was used.
Property
2.0.0.0
4.0.0.0
System.Int32
To be added.
This property is set by calling the method.
This property is used with the , , , , , , and methods.
Gets the maximum amount of data, in bytes, to send or receive in an asynchronous operation.
Property
2.0.0.0
4.0.0.0
System.Boolean
To be added.
This property is used to alter the behavior of method. If true, a socket disconnected by the method can be reused after disconnect completion in subsequent socket accept or connect operations.
Gets or sets a value that specifies if socket can be reused after a disconnect operation.
Method
4.0.0.0
System.Void
This method is called by the public Dispose() method and the method. Dispose() invokes the protected Dispose(Boolean) method with the parameter set to true. invokes Dispose with set to false.
When the parameter is true, this method releases all resources held by any managed objects that this references. This method invokes the Dispose() method of each referenced object.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
Releases the unmanaged resources used by the instance and optionally disposes of the managed resources.
Method
2.0.0.0
4.0.0.0
System.Void
The class finalizer closes the and free resources associated with the .
Frees resources used by the class.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.SocketAsyncOperation
To be added.
This property describes the asynchronous socket operation that was most recently completed using this object. The value of this property will be until the instance is used to begin an asynchronous socket operation. The property will then be set to the type of operation being performed in the methods that take the as a parameter. This property more easily facilitates using a single completion callback delegate for multiple kinds of asynchronous socket operations.
This property remains valid in a instance until the instance is used for another asynchronous socket (xxxAsync) operation.
This property is set by all asynchronous socket (xxxAsync) methods.
Calling an asynchronous socket method (xxxAsync) on the class sets this property value. This property is intended for use with the SocketAsyncCallback completion routine implemented by the application.
Gets the type of socket operation most recently performed with this context object.
Property
2.0.0.0
4.0.0.0
System.Int32
To be added.
This property describes the starting byte offset of data in the property. This value is set by calling the method.
This property does not apply to the property.
This property is used with the , , , , , , and methods.
Gets the offset, in bytes, into the data buffer referenced by the property.
Method
2.0.0.0
4.0.0.0
System.Void
This method is not callable by user code. This method gets called by the internals of the object when the current operation is complete. This method is used with all asynchronous socket (xxxAsync) methods.
An application that creates a class inheriting from can override this method to hook into this completion notification and clean up any resources that it allocated for the operation. The default implementation just raises the event.
This method is used to hook up an event handler to be used as the completion callback for a subsequent asynchronous socket operation. The caller must implement at least one callback delegate inherited from this method prior to starting an asynchronous socket operation using one of the asynchronous (xxxAsync) methods on the class.
The caller's method provides a way for client applications to complete an asynchronous socket operation. A callback delegate must be implemented when an asynchronous socket operation is initiated. The completion callback delegate(s) inherited from the method must contain program logic to finish processing the asynchronous socket operation for the client.
When an asynchronous operation is signaled, the application uses the object parameter to obtain status of the completed asynchronous socket operation.
Represents a method that is called when an asynchronous operation completes.
The event that is signaled.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.IPPacketInformation
To be added.
This property provides information about a packet received using the method.
This property is used with the method.
Gets the IP address and interface of a received packet.
Property
2.0.0.0
4.0.0.0
System.Net.EndPoint
To be added.
This property specifies the remote endpoint. This property can specify the remote endpoint to which to connect using the method. This property can specify the remote endpoint to which to send data using method. This property can specify the remote endpoint from which data was received using the or methods.
This remote endpoint specified by this property can include an IPv4 or IPv6 address.
This property is used with the , , , or methods.
Gets or sets the remote IP endpoint for an asynchronous operation.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.SendPacketsElement[]
To be added.
The array of buffers can represent a file or files in memory or a set of memory data buffers. This property is used with the method.
Gets or sets an array of buffers to be sent for an asynchronous operation used by the method.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.TransmitFileOptions
To be added.
This property specifies the that are used by the method.
Gets or sets a bitwise combination of values for an asynchronous operation used by the method.
Property
2.0.0.0
4.0.0.0
System.MonoTODO("unused property")
System.Int32
To be added.
Set this property to zero to let the sockets layer select a default send size. Setting this property to 0xFFFFFFFF enables the caller to control the size and content of each send request, achieved by using the property. This capability is useful for message protocols that place limitations on the size of individual send requests.
Gets or sets the size, in bytes, of the data block used in the send operation.
Method
2.0.0.0
4.0.0.0
System.Void
The and parameters can't be negative numbers. The combination of the and parameters must be in bounds of the buffer array in the property.
This method sets the property to the parameter and the property to the parameter. If the property is null, this method ignores the and parameters and sets the and properties to 0.
This method does not change the property.
Sets the data buffer to use with an asynchronous socket method.
The offset, in bytes, in the data buffer where the operation starts.
The maximum amount of data, in bytes, to send or receive in the buffer.
Method
2.0.0.0
4.0.0.0
System.Void
The and parameters can't be negative numbers. The combination of the and parameters must be in bounds of the data array in the parameter.
This method sets the property to the parameter, the property to the parameter, and the property to the parameter.
Sets the data buffer to use with an asynchronous socket method.
The data buffer to use with an asynchronous socket method.
The offset, in bytes, in the data buffer where the operation starts.
The maximum amount of data, in bytes, to send or receive in the buffer.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.SocketError
To be added.
This property provides the completion status of an asynchronous socket operation. A value of indicates successful completion of an operation. This property is primarily used in an application’s event handler routine.
This property is used with all of the asynchronous socket (xxxAsync) methods.
Gets or sets the result of the asynchronous socket operation.
Property
2.0.0.0
4.0.0.0
System.Net.Sockets.SocketFlags
To be added.
The property specifies the bitwise combination of the to be used for an asynchronous socket operation.
This property is used with the , , , and methods.
Gets the results of an asynchronous socket operation or sets the behavior of an asynchronous operation.
Method
2.0.0.0
System.Void
To be added.
To be added.
Property
2.0.0.0
4.0.0.0
System.Object
To be added.
This property can be used by an application to associate an application state object with the object. Primarily, this property is a way for an application to pass state to the application’s event handler (for example, the asynchronous operation completion method).
This property is used with all of the asynchronous socket (xxxAsync) methods.
Gets or sets a user or application object associated with this asynchronous socket operation.