แก้ไข

แชร์ผ่าน


SocketTaskExtensions.SendToAsync Method

Definition

Sends data asynchronously to a specific remote host.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<int> ^ SendToAsync(System::Net::Sockets::Socket ^ socket, ArraySegment<System::Byte> buffer, System::Net::Sockets::SocketFlags socketFlags, System::Net::EndPoint ^ remoteEP);
public static System.Threading.Tasks.Task<int> SendToAsync (this System.Net.Sockets.Socket socket, ArraySegment<byte> buffer, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP);
static member SendToAsync : System.Net.Sockets.Socket * ArraySegment<byte> * System.Net.Sockets.SocketFlags * System.Net.EndPoint -> System.Threading.Tasks.Task<int>
<Extension()>
Public Function SendToAsync (socket As Socket, buffer As ArraySegment(Of Byte), socketFlags As SocketFlags, remoteEP As EndPoint) As Task(Of Integer)

Parameters

socket
Socket

The socket to perform the operation on.

buffer
ArraySegment<Byte>

An array that contains the data to send.

socketFlags
SocketFlags

A bitwise combination of the SocketFlags values.

remoteEP
EndPoint

An EndPoint that represents the remote device.

Returns

An asynchronous task that completes with number of bytes sent if the operation was successful. Otherwise, the task will complete with an invalid socket error.

Exceptions

remoteEP is null.

An error occurred when attempting to access the socket.

The Socket has been closed.

Applies to