Dart.Sockets Namespace > UdpBase Class : ReceiveAsync Method |
'Declaration <SecuritySafeCriticalAttribute()> Public Sub ReceiveAsync( _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal size As Integer, _ ByVal socketFlags As SocketFlags, _ ByVal callback As UdpAsyncCallback, _ ByVal state As Object _ )
'Usage Dim instance As UdpBase Dim buffer() As Byte Dim offset As Integer Dim size As Integer Dim socketFlags As SocketFlags Dim callback As UdpAsyncCallback Dim state As Object instance.ReceiveAsync(buffer, offset, size, socketFlags, callback, state)
[SecuritySafeCritical()] public void ReceiveAsync( byte[] buffer, int offset, int size, SocketFlags socketFlags, UdpAsyncCallback callback, object state )
[SecuritySafeCritical()] public: void ReceiveAsync( byte[]* buffer, int offset, int size, SocketFlags socketFlags, UdpAsyncCallback* callback, Object* state )
[SecuritySafeCritical()] public: void ReceiveAsync( array<byte>^ buffer, int offset, int size, SocketFlags socketFlags, UdpAsyncCallback^ callback, Object^ state )
Exception | Description |
---|---|
System.ArgumentNullException | buffer is null. |
Use the ReceiveAsync method to receive a datagram into buffer asynchronously. This method returns immediately and invokes the provided UdpAsyncCompleted delegate on an IO Completion thread after a datagram has been received.
A UDP datagram provides little functionality over an IP datagram, adding a port number field (allows demultiplexing on the receiving host) and a checksum field (provides basic error handling). Unlike TCP, UDP datagrams are sent as a unit. If Send is called 3 times to send 3 datagrams to a host, the receiving host will have to call Receive 3 times. Also, the size of each datagram sent will equal the size of each datagram received by the receiving host. In addition, since UDP is a connectionless protocol, datagrams sent to the host are not guaranteed to be delivered. Therefore, any required error checking (outside of UDP's checksum implementation) will have to be done by the application-layer protocol.