Share via


UdpSingleSourceMulticastClient.BeginSendToSource 方法

定义

注意

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

开始执行向之前指定的源发送单播数据包的操作。

public:
 IAsyncResult ^ BeginSendToSource(cli::array <System::Byte> ^ buffer, int offset, int count, int remotePort, AsyncCallback ^ callback, System::Object ^ state);
[System.Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)]
public IAsyncResult BeginSendToSource (byte[] buffer, int offset, int count, int remotePort, AsyncCallback callback, object state);
[<System.Obsolete("This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.", true)>]
member this.BeginSendToSource : byte[] * int * int * int * AsyncCallback * obj -> IAsyncResult
Public Function BeginSendToSource (buffer As Byte(), offset As Integer, count As Integer, remotePort As Integer, callback As AsyncCallback, state As Object) As IAsyncResult

参数

buffer
Byte[]

包含要发送的数据的缓冲区。

offset
Int32

要从中读取待发送数据的从 buffer 开始处的偏移量(以字节为单位)。

count
Int32

要从 buffer 发送的字节数。

remotePort
Int32

要向其发送数据包的远程端口。 远程地址由 UdpSingleSourceMulticastClient(IPAddress, IPAddress, Int32) 构造函数指定。

callback
AsyncCallback

要在此操作完成时调用的回调方法。

state
Object

要为此操作传递给 callback 方法的可选状态信息。

返回

引用此操作的 IAsyncResult

属性

例外

buffer 为 null 引用(在 Visual Basic 中为 Nothing)。

offset 小于 0

- 或 -

offset 大于 buffer 的长度。

- 或 -

count 小于 0

- 或 -

offset 加上此计数大于 buffer 的长度。

- 或 -

remotePort 小于 0 或大于 65,535。

尚未联接多播组。

尝试访问套接字时出错。

注解

方法 BeginSendToSource 开始将 UDP 数据包发送到先前指定的源的操作。

某些协议使用此信息传递流控制、服务质量统计信息或恢复消息。

发送数据包后, callback 将调用 参数中指定的方法。

客户端必须已完成多播组的加入。

如果 参数中指定的 remotePort 目标端口小于 1,024, SocketException 则会使用 AccessDenied引发 。

如果发送操作同步失败,则可能会发生套接字故障,尽管这在 UDP 中并不常见。 如果发生套接字故障, SocketException 将引发 。 收到的错误指定为 枚举的成员 SocketError

适用于