PowerTCP Sockets for .NET
ReceiveAsync Method (UdpBase)




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.
A UdpAsyncCallback delegate referencing the method to invoke on an IO completion thread when the operation completes.
Object to pass into the callback method when the operation completes; can be null.
Receive a datagram asynchronously.
Syntax
'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
) 

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.
callback
A UdpAsyncCallback delegate referencing the method to invoke on an IO completion thread when the operation completes.
state
Object to pass into the callback method when the operation completes; can be null.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionbuffer is null.
Remarks

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.

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