UdpSingleSourceMulticastClient.BeginReceiveFromSource 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
開始從已加入的多點傳送群組接收封包之作業,並在封包從指定的寄件者送達群組時,叫用指定的回呼。
public:
IAsyncResult ^ BeginReceiveFromSource(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 BeginReceiveFromSource (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.BeginReceiveFromSource : byte[] * int * int * AsyncCallback * obj -> IAsyncResult
Public Function BeginReceiveFromSource (buffer As Byte(), offset As Integer, count As Integer, callback As AsyncCallback, state As Object) As IAsyncResult
參數
- buffer
- Byte[]
要儲存已接收資料的緩衝區。
- offset
- Int32
距離應儲存資料之 buffer
開頭的位移 (以位元組為單位)。
- count
- Int32
要接收並儲存在 buffer
中的最大位元組數。
- callback
- AsyncCallback
作業完成時要叫用的回呼方法。
- state
- Object
要傳遞給這項作業之 callback
方法的選擇性狀態資訊。
傳回
參考這項作業的 IAsyncResult。
- 屬性
例外狀況
buffer
是 null 參考 (在 Visual Basic 中為 Nothing)。
offset
小於 0
-或-
offset
大於 buffer
的長度。
-或-
count
小於 0
-或-
offset
加上這個計數會大於 buffer
的長度。
尚未聯結多點傳送群組。
嘗試存取接收通訊端時發生錯誤。
備註
BeginReceiveFromSource方法會開始從單一傳送者接收來自聯結多播群組的 UDP 封包。 本機埠、多播群組和寄件者來源位址是在函式中指定 UdpSingleSourceMulticastClient 。 多播用戶端也必須已完成與多播群組的聯結。
當封包收到時,會叫用參數中指定的方法 callback
。
如果接收作業以同步方式失敗,可能會發生通訊端失敗,雖然 UDP 的情況並不常見。 如果發生通訊端失敗, SocketException 就會擲回。 收到的錯誤會指定為列舉的成員 SocketError 。