PowerTCP Sockets for .NET
ReceiveTaskAsync Method




A byte array to be filled with the data received.
Location where received bytes are to placed.
The number of bytes to receive.
User specified SocketFlags.
Receive a datagram.
Syntax
'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
) 

Parameters

buffer
A byte array to be filled with the data received.
offset
Location where received bytes are to placed.
size
The number of bytes to receive.
socketFlags
User specified SocketFlags.

Return Value

An awaitable task that represents the asynchronous receive operation. The value of the TResult parameter contains the Datagram object encapsulating the received data (null if the socket is closed).
Exceptions
ExceptionDescription
System.ArgumentNullExceptionbuffer is null.
Remarks

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.

See Also

Reference

UdpBase Class
UdpBase Members


PowerTCP Sockets for .NET Documentation Version 4.5
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic