See Also

Udp Class  | Udp Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerTCP SSL Sockets for .NET

EndSend Event

Dart.PowerTCP.SslSockets Namespace > Udp Class : EndSend Event (Udp)

Raised when the BeginSend request completes.

[Visual Basic]
<CategoryAttribute("Completion Notification")> <DescriptionAttribute("Raised when the BeginSend() request completes")> Public Event EndSend() As DatagramEventHandler
[C#]
[CategoryAttribute("Completion Notification")] [DescriptionAttribute("Raised when the BeginSend() request completes")] public event DatagramEventHandler EndSend();
[C++]
[CategoryAttribute("Completion Notification")] [DescriptionAttribute("Raised when the BeginSend() request completes")] public: __event DatagramEventHandler* EndSend();
[C++/CLI]
[CategoryAttribute("Completion Notification")] [DescriptionAttribute("Raised when the BeginSend() request completes")] public: event DatagramEventHandler^ EndSend();

Event Data

The event handler receives an argument of type DatagramEventArgs containing data related to this event. The following DatagramEventArgs properties provide information specific to this event.

PropertyDescription
Datagram Gets the Datagram object that represents the datagram for which the event was raised.
Exception Gets any exception which occurred during the asynchronous operation.
State Gets the object that was included as part of the associated method call.

Remarks

This event is raised when the asynchronous method call BeginSend completes. A DatagramEventArgs object is passed into the event, containing information about the event, such as the data sent.

If any errors occurred during the asynchronous operation, they would be returned in the DatagramEventArgs object, check Exception to check for any exception.

For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see the topic, Using Events In PowerTCP.

If you are using the Udp component as a reference, you must create a method to handle the event yourself.

This event MUST be implemented if you are using the BeginSend method.

Example

The following example demonstrates sending data asynchronously.

[Visual Basic] 

Private Sub AsynchTest()
   ' Begin listening for datagrams.
   Udp1.Open(1111)

   ' Asynchronously send a datagram. EndSend event will be raised upon completion.
   Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes("test")
   Udp1.BeginSend(buffer, "weezer", 8888)
End Sub

Private Sub Udp1_EndSend(ByVal sender As Object, ByVal e As DatagramEventArgs) Handles Udp1.EndSend
   If e.Exception Is Nothing Then
      Debug.WriteLine("Data sent: " + e.Datagram.ToString())
   Else
      Debug.WriteLine("Exception returned from event: " + e.Exception.ToString())
   End If
End Sub

[C#] 


private void AsynchTest()
{
   
// Begin listening for datagrams.
   
udp1.Open(1111);

   
// Asynchronously send a datagram. EndSend event will be raised upon completion.
   
byte[] buffer = System.Text.Encoding.Default.GetBytes("test");
   udp1.BeginSend(buffer,
"MyEchoServer", 7);
}

private void udp1_EndSend(object sender, DatagramEventArgs e)
{
  
if(e.Exception == null)
  {
     Debug.WriteLine(
"Data sent: " + e.Datagram.ToString());
  }
  
else
  {
     
Debug.WriteLine("Exception returned from event: " + e.Exception.ToString());
  }
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Udp Class  | Udp Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.