SocketTaskExtensions.SendAsync Method
Definition
Overloads
SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken) |
Sends data to a connected socket. |
SendAsync(Socket, ArraySegment<Byte>, SocketFlags) |
Sends data to a connected socket. |
SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags) |
Sends data to a connected socket. |
SendAsync(Socket, ReadOnlyMemory<Byte>, SocketFlags, CancellationToken)
Sends data to a connected socket.
public static System.Threading.Tasks.ValueTask<int> SendAsync (this System.Net.Sockets.Socket socket, ReadOnlyMemory<byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Threading.CancellationToken cancellationToken = default);
static member SendAsync : System.Net.Sockets.Socket * ReadOnlyMemory<byte> * System.Net.Sockets.SocketFlags * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
<Extension()>
Public Function SendAsync (socket As Socket, buffer As ReadOnlyMemory(Of Byte), socketFlags As SocketFlags, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)
Parameters
- socket
- Socket
The socket to perform the operation on.
- buffer
- ReadOnlyMemory<Byte>
A region of memory that contains the data to send.
- socketFlags
- SocketFlags
A bitwise combination of the SocketFlags values.
- cancellationToken
- CancellationToken
A cancellation token that can be used to signal the asynchronous operation should be canceled.
Returns
A task that completes with number of bytes sent to the socket if the operation was successful. Otherwise, the task will complete with an invalid socket error.
Applies to
SendAsync(Socket, ArraySegment<Byte>, SocketFlags)
Sends data to a connected socket.
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<int> ^ SendAsync(System::Net::Sockets::Socket ^ socket, ArraySegment<System::Byte> buffer, System::Net::Sockets::SocketFlags socketFlags);
public static System.Threading.Tasks.Task<int> SendAsync (this System.Net.Sockets.Socket socket, ArraySegment<byte> buffer, System.Net.Sockets.SocketFlags socketFlags);
static member SendAsync : System.Net.Sockets.Socket * ArraySegment<byte> * System.Net.Sockets.SocketFlags -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function SendAsync (socket As Socket, buffer As ArraySegment(Of Byte), socketFlags As SocketFlags) As Task(Of Integer)
Parameters
- socket
- Socket
The socket to perform the operation on.
- buffer
- ArraySegment<Byte>
An array of type Byte that contains the data to send.
- socketFlags
- SocketFlags
A bitwise combination of the SocketFlags values.
Returns
An asynchronous task that completes with number of bytes sent to the socket if the operation was successful. Otherwise, the task will complete with an invalid socket error.
Applies to
SendAsync(Socket, IList<ArraySegment<Byte>>, SocketFlags)
Sends data to a connected socket.
public:
[System::Runtime::CompilerServices::Extension]
static System::Threading::Tasks::Task<int> ^ SendAsync(System::Net::Sockets::Socket ^ socket, System::Collections::Generic::IList<ArraySegment<System::Byte>> ^ buffers, System::Net::Sockets::SocketFlags socketFlags);
public static System.Threading.Tasks.Task<int> SendAsync (this System.Net.Sockets.Socket socket, System.Collections.Generic.IList<ArraySegment<byte>> buffers, System.Net.Sockets.SocketFlags socketFlags);
static member SendAsync : System.Net.Sockets.Socket * System.Collections.Generic.IList<ArraySegment<byte>> * System.Net.Sockets.SocketFlags -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function SendAsync (socket As Socket, buffers As IList(Of ArraySegment(Of Byte)), socketFlags As SocketFlags) As Task(Of Integer)
Parameters
- socket
- Socket
The socket to perform the operation on.
- buffers
- IList<ArraySegment<Byte>>
An array that contains the data to send.
- socketFlags
- SocketFlags
A bitwise combination of the SocketFlags values.
Returns
An asynchronous task that completes with number of bytes sent to the socket if the operation was successful. Otherwise, the task will complete with an invalid socket error.