PowerTCP Sockets for .NET
SendAsync Method (UdpBase)




A byte array containing the data to send.
Starting offset within buffer for sending.
Number of bytes to send.
A bitwise combination of special use sending parameters.
The System.Net.IPEndPoint representing the remote hosts's IP address and port.
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.
Send a datagram to the specified IPEndPoint asynchronously, specifying a buffer, offset, length and SocketFlags value.
Syntax
'Declaration
 
<SecuritySafeCriticalAttribute()>
Public Sub SendAsync( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer, _
   ByVal socketFlags As SocketFlags, _
   ByVal destination As IPEndPoint, _
   ByVal callback As UdpAsyncCallback, _
   ByVal state As Object _
) 
'Usage
 
Dim instance As UdpBase
Dim buffer() As Byte
Dim offset As Integer
Dim count As Integer
Dim socketFlags As SocketFlags
Dim destination As IPEndPoint
Dim callback As UdpAsyncCallback
Dim state As Object
 
instance.SendAsync(buffer, offset, count, socketFlags, destination, callback, state)
[SecuritySafeCritical()]
public void SendAsync( 
   byte[] buffer,
   int offset,
   int count,
   SocketFlags socketFlags,
   IPEndPoint destination,
   UdpAsyncCallback callback,
   object state
)
[SecuritySafeCritical()]
public: void SendAsync( 
   byte[]* buffer,
   int offset,
   int count,
   SocketFlags socketFlags,
   IPEndPoint* destination,
   UdpAsyncCallback* callback,
   Object* state
) 
[SecuritySafeCritical()]
public:
void SendAsync( 
   array<byte>^ buffer,
   int offset,
   int count,
   SocketFlags socketFlags,
   IPEndPoint^ destination,
   UdpAsyncCallback^ callback,
   Object^ state
) 

Parameters

buffer
A byte array containing the data to send.
offset
Starting offset within buffer for sending.
count
Number of bytes to send.
socketFlags
A bitwise combination of special use sending parameters.
destination
The System.Net.IPEndPoint representing the remote hosts's IP address and port.
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.
System.Net.Sockets.SocketExceptionThe remote address is unknown, invalid, or unable to be resolved.
System.ArgumentOutOfRangeExceptionThe remote port is out of the range of valid values.
--or--
offset or count is less than 0.
System.ArgumentExceptionoffset + count is greater than the length of buffer.
Remarks

Use the SendAsync method to sent a datagram created from the data contained in buffer to the specified hostNameOrAddress asynchronously.

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 SendAsync 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, any 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.

To send a broadcast datagram, use "255.255.255.255" as the remote address. To send a multicast datagram, use the multicast group address as the remote address after first joining a multicast group by using JoinMulitcastGroup.

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