Dart.Sockets Namespace > UdpBase Class : ReceiveTaskAsync Method |
'Declaration Public Function ReceiveTaskAsync( _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal size As Integer, _ ByVal socketFlags As SocketFlags _ ) As Task(Of Datagram)
'Usage Dim instance As UdpBase Dim buffer() As Byte Dim offset As Integer Dim size As Integer Dim socketFlags As SocketFlags Dim value As Task(Of Datagram) value = instance.ReceiveTaskAsync(buffer, offset, size, socketFlags)
public Task<Datagram> ReceiveTaskAsync( byte[] buffer, int offset, int size, SocketFlags socketFlags )
public: Task<Datagram*>* ReceiveTaskAsync( byte[]* buffer, int offset, int size, SocketFlags socketFlags )
public: Task<Datagram^>^ ReceiveTaskAsync( array<byte>^ buffer, int offset, int size, SocketFlags socketFlags )
Exception | Description |
---|---|
System.ArgumentNullException | buffer is null. |
Use the Receive method to receive a datagram into buffer. This method also returns a Datagram object encapsulating the datagram received. Segment.Buffer contains the actual datagram data (equivalent to buffer). Datagram.Origin contains the endpoint of the remote host from which the datagram was sent.
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.