UdpAnySourceMulticastClient.BeginSendToGroup(Byte[], Int32, Int32, AsyncCallback, Object) 方法

定义

注意

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

开始执行将数据包发送到已联接的多播组的操作,并在已将数据包发送到组时调用指定的回调。Begins the operation of sending a packet to a joined multicast group and invokes the specified callback when a packet has been sent to the group.

public:
 IAsyncResult ^ BeginSendToGroup(cli::array <System::Byte> ^ buffer, int offset, int count, 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 BeginSendToGroup (byte[] buffer, int offset, int count, 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.BeginSendToGroup : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Function BeginSendToGroup (buffer As Byte(), offset As Integer, count As Integer, callback As AsyncCallback, state As Object) As IAsyncResult

参数

buffer
Byte[]

包含要发送的数据的缓冲区。The buffer that contains the data to send.

offset
Int32

要从中读取待发送数据的从 buffer 开始处的偏移量(以字节为单位)。The offset, in bytes, from the beginning of the buffer to read the data to be sent.

count
Int32

要从 buffer 发送的字节数。The number of bytes to send from the buffer.

callback
AsyncCallback

要在此操作完成时调用的回调方法。The callback method to invoke when the operation completes.

state
Object

要为此操作传递给 callback 方法的可选状态信息。Optional state information to pass to the callback method for this operation.

返回

IAsyncResult

引用此操作的 IAsyncResultAn IAsyncResult that references this operation.

属性

例外

buffer 为 null 引用(在 Visual Basic 中为 Nothing)。buffer is a null reference (Nothing in Visual Basic).

offset 小于 0offset is less than 0 - 或 --or- offset 大于 buffer 的长度。offset is greater than the length of the buffer.

- 或 --or- count 小于 0count is less than 0 - 或 --or- offset 加上此计数大于 buffer 的长度。offset plus the count is greater than the length of the buffer.

尚未联接多播组。The multicast group has not yet been joined.

尝试访问套接字时出错。An error occurred when attempting to access the socket.

注解

BeginSendToGroup方法开始将 UDP 数据包发送到已联接的多播组的操作。The BeginSendToGroup method begins an operation of sending a UDP packet to the joined multicast group.

客户端必须已完成到多播组的联接。The client must have completed a join to the multicast group.

接收到数据包时,将调用参数中指定的方法 callbackThe method specified in the callback parameter is invoked when a packet has received.

如果接收操作同步失败,则可能会出现套接字故障,但这种情况不太常见。It is possible to have a socket failure if a receive operation fails synchronously, although this is uncommon with UDP. 如果出现套接字故障, SocketException 则会引发。If a socket failure occurs, a SocketException is thrown. 收到的错误被指定为枚举的成员 SocketErrorThe error received is specified as a member of the SocketError enumeration.

适用于