Socket.SendAsync Method (SocketAsyncEventArgs)
Sends data asynchronously to a connected Socket object.
Assembly: System (in System.dll)
Return ValueType: System.Boolean
Returns true if the I/O operation is pending. The SocketAsyncEventArgs.Completed event on the e parameter will be raised upon completion of the operation.
Returns false if the I/O operation completed synchronously. In this case, The SocketAsyncEventArgs.Completed event on the e parameter will not be raised and the e object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
A socket operation was already in progress using the System.Net.Sockets.SocketAsyncEventArgs object specified in the e parameter.
Windows XP or later is required for this method.
The Socket has been closed.
Themethod is used to write outgoing data from one or more buffers on a connection-oriented socket. This method can also be used, however, on connectionless sockets that have specified a remote host on a connect operation.
The following properties and events on the System.Net.Sockets.SocketAsyncEventArgs object are required to successfully call this method:
The caller may set the SocketAsyncEventArgs.UserToken property to any user state object desired before calling the method, so that the information will be retrievable in the callback method. If the callback needs more information than a single object, a small class can be created to hold the other required state information as members.
Calling themethod gives you the ability to send data within a separate execution thread.
For message-oriented sockets, do not exceed the maximum message size of the underlying Windows sockets service provider. If the data is too long to pass atomically through the underlying service provider, no data is transmitted and the SocketException with the SocketAsyncEventArgs.SocketError set to the native Winsock WSAEMSGSIZE error code (10040).method throws a
Note that the successful completion of themethod does not indicate that the data was successfully delivered.
Available since 10
Available since 2.0
Available since 2.0
Windows Phone Silverlight
Available since 7.1